Skip to content

Commit d95dd67

Browse files
averissimogithub-actions[bot]llrs-roche
authored
Adds rmarkdown module (#944)
# 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]>
1 parent 1bb0988 commit d95dd67

File tree

10 files changed

+775
-1
lines changed

10 files changed

+775
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Imports:
4848
lattice (>= 0.18-4),
4949
lifecycle (>= 0.2.0),
5050
MASS (>= 7.3-60),
51+
rmarkdown (>= 2.23),
5152
rtables (>= 0.6.11),
5253
scales (>= 1.3.0),
5354
shinyjs (>= 2.1.0),
@@ -73,7 +74,6 @@ Suggests:
7374
nestcolor (>= 0.1.0),
7475
pkgload,
7576
rlang (>= 1.0.0),
76-
rmarkdown (>= 2.23),
7777
roxy.shinylive,
7878
rvest,
7979
shinytest2,

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ S3method(create_sparklines,default)
88
S3method(create_sparklines,factor)
99
S3method(create_sparklines,logical)
1010
S3method(create_sparklines,numeric)
11+
S3method(teal.reporter::to_rmd,markdown_internal)
12+
S3method(tools::toHTML,markdown_internal)
1113
export(add_facet_labels)
1214
export(get_scatterplotmatrix_stats)
1315
export(tm_a_pca)
@@ -23,6 +25,7 @@ export(tm_g_scatterplot)
2325
export(tm_g_scatterplotmatrix)
2426
export(tm_missing_data)
2527
export(tm_outliers)
28+
export(tm_rmarkdown)
2629
export(tm_t_crosstable)
2730
export(tm_variable_browser)
2831
import(ggplot2)

0 commit comments

Comments
 (0)