Commit d95dd67
Adds
# Pull Request
<!--- Replace `#nnn` with your issue link for reference. -->
- Fixes insightsengineering/coredev-tasks#675
Thanks to @StefanThoma's for working on the first prototype
### Changes description
- Adds rmarkdown module
- Renders the output to module UI and to Reporter
- Source code is not verified as it adds a comment on how to render it
- Adds download button to get the original Rmd file
- Option in module to enable or disable this functionality
- downloaded Rmd has module's data included (data pre-processing +
filter)
- Uses `extra_transform` parameter to add "generic decorators" to the
top of the UI
- name is temporary
- [x] Ensure figures are displayed properly in reporter (PDF output)
- [x] Avoid encoding images to base64 (mayb keep it in raw or
equivalent)
### To discuss
- Should we render the `.R` to get all the R code from the report and
add it to the code of the `qenv`?
- [limitation] Use of `markdown` when rendering doesn't print title nor
author
- Rendering it on the page breaks `teal`
- Wrapping in `iframe` doesn't extend full height and then creates
strange reports
- Should we use `transformers` to add extra input / data manipulation
- Or keep a parameters that allows to add transforms _(for example extra
inputs)_ to the module by the app developer
(topics below added from conversation with @gogonzo )
- should `teal_report` contain markdown elements?
- should `teal_data` evaluate `rmarkdown::render()` and include this to
`@code`
- should markdown be evaluated with `rmarkdown::render(envir = <qenv>)`
instead of `params = list()`?
- visibility concern here on developing the Rmd
### App (same 2nd one in example, but with `download = TRUE`)
```r
pkgload::load_all("../teal.modules.general")
data <- teal_data()
data <- within(data, {
CO2 <- CO2
CO2[["primary_key"]] <- seq_len(nrow(CO2))
})
join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key"))
static_decorator <- teal_transform_module(
label = "N Cols selector",
ui = function(id) {
ns <- NS(id)
tags$div(
numericInput(ns("n_rows"), "Show n rows", value = 5, min = 0, max = 200, step = 5)
)
},
server = function(id, data) {
moduleServer(id, function(input, output, session) {
reactive({
req(data())
within(data(), {
n_rows <- n_rows_value
}, n_rows_value = input$n_rows)
})
})
}
)
app <- init(
data = data,
modules = modules(
tm_rmarkdown(
label = "RMarkdown Module",
rmd_content = readLines(system.file(file.path("sample_files", "co2_example.Rmd"), package = "teal.modules.general")),
allow_download = TRUE,
extra_transform = list(static_decorator)
)
)
) |> shiny::runApp()
```
---------
Signed-off-by: André Veríssimo <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lluís Revilla <[email protected]>rmarkdown module (#944)1 parent 1bb0988 commit d95dd67
File tree
10 files changed
+775
-1
lines changed- R
- inst
- sample_files
- man
- tests/testthat
10 files changed
+775
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
0 commit comments