Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗃️ Decorators feature branch #1252

Merged
merged 94 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
7c29d47
feat: add decorator wrapper
averissimo Nov 25, 2024
45da7ca
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 25, 2024
537b2c1
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 26, 2024
84a00fd
add decorators @param to standard template arguments
m7pr Nov 26, 2024
58e65bf
move decorators parameter to module templeate parameters
m7pr Nov 26, 2024
b684fa5
bring check_decorators from tmg
m7pr Nov 26, 2024
0805fa4
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 26, 2024
29f22c7
rename decorators to transformators in ui_decorate_teal_data
m7pr Nov 26, 2024
3df00dc
Merge branch '1187_decorate_output@main' of https://github.com/insigh…
m7pr Nov 26, 2024
dc682cd
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 26, 2024
93c6af5
introduce decorators for `tm_g_pp_vitals`
m7pr Nov 27, 2024
1899063
revert changes for vitals
m7pr Nov 27, 2024
64b9d1d
fix: update wrapper to use 'inner' in srv_decorate_teal_data
averissimo Nov 27, 2024
af2a623
Merge branch 'main' into 1187_decorate_output@main
m7pr Nov 27, 2024
b033451
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 27, 2024
064bcb2
add normalize_decorators
m7pr Nov 27, 2024
a677777
fix normalize_decorators
m7pr Nov 27, 2024
1e9a78c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 27, 2024
55cd3d3
update utils from tmg
m7pr Nov 28, 2024
b565310
introduce decorators for `tm_g_ci` (#1265)
llrs-roche Nov 28, 2024
2276fca
Introduce decorators to `tm_g_forest_rsp` (#1266)
llrs-roche Nov 28, 2024
fd17aed
introduce decorators for `tm_g_forest_tte` (#1264)
m7pr Nov 28, 2024
4e747f9
introduce decorators for `tm_a_gee` (#1262)
m7pr Nov 28, 2024
fcc3682
introduce decorators for `tm_g_ipp` (#1263)
m7pr Nov 28, 2024
31fdab6
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 28, 2024
98520eb
introduce decorators to `tm_g_pp_patient_timeline` (#1270)
llrs-roche Nov 29, 2024
5cf2166
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 29, 2024
f462d60
introduce decorators for `tm_g_pp_therapy` (#1268)
m7pr Nov 29, 2024
d6416e1
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 29, 2024
25d9220
chore: necessary for pre-commit
averissimo Nov 29, 2024
956bc9e
chore: remove print plot expression
averissimo Nov 29, 2024
e7132b5
Revert "chore: remove print plot expression"
averissimo Nov 29, 2024
444cd0b
feat: add template for decorators parameter
averissimo Nov 29, 2024
bb3ae23
chore: use decorators template instead of shared parameter
averissimo Nov 29, 2024
e1976b6
chore: change order of null.ok
averissimo Nov 29, 2024
3ae43d2
introduce decorators for `tm_g_pp_vitals` (#1261)
m7pr Nov 29, 2024
d7b036e
introduce decorators for `tm_t_abnormality` (#1257)
m7pr Nov 29, 2024
af7ecff
Introduce decorators for `tm_g_km` (#1254)
m7pr Nov 29, 2024
078fc51
Introduce decorators for `tm_g_lineplot` (#1255)
m7pr Nov 29, 2024
dab7f4e
introduce decorators for `tm_t_ancova` (#1256)
m7pr Nov 29, 2024
e3bc080
introduce decorators for `tm_t_abnormality_by_worst_grade` (#1260)
m7pr Nov 29, 2024
69659e7
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Nov 29, 2024
1572839
Merged origin/main into 1187_decorate_output@main
llrs-roche Dec 2, 2024
132c4e6
fix: remove teal-only function
averissimo Dec 3, 2024
070e129
Include decorators for `tm_t_events_summary` (#1278)
llrs-roche Dec 4, 2024
6ddb425
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 4, 2024
37e42a2
Introduce decorators for `tm_t_coxreg` (#1274)
llrs-roche Dec 4, 2024
28ba4c4
Introduce decorator for `tm_t_events_patyear` (#1277)
llrs-roche Dec 4, 2024
5b87fdc
Introduce decorator for `tm_t_events` (#1275)
llrs-roche Dec 4, 2024
78c451d
Introduce decorators for `tm_t_binary_outcome` (#1273)
llrs-roche Dec 4, 2024
5fdc43e
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 4, 2024
1ac634c
introduce decorators for `tm_g_barchart_simple` (#1267)
m7pr Dec 4, 2024
a9eb913
chore: fix R CMD check with missing arguments and using rlang that is…
averissimo Dec 4, 2024
a78c0ba
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 4, 2024
06ab990
Add decorators to `tm t mult events` (#1281)
averissimo Dec 5, 2024
b8c3c71
Introduce decorators for `tm_t_tte` (#1280)
averissimo Dec 5, 2024
cbb58b7
docs: documentation simplification
averissimo Dec 5, 2024
e3be031
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 5, 2024
5822470
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 5, 2024
2a447e4
docs: minor typo gg -> ggplot2
averissimo Dec 5, 2024
4829c00
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 5, 2024
a6e730c
introduce decorators for `tm_g_pp_adverse_events` (#1269)
m7pr Dec 9, 2024
a55de1f
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 9, 2024
bd975e5
Adds decorators to `tm_t_pp_medical_history` (#1289)
averissimo Dec 9, 2024
4d6de2d
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 9, 2024
59960ba
Adds decorators to `tm_t_logistic` (#1290)
averissimo Dec 10, 2024
3e98e81
Adds decorators to `tm_t_summary` (#1293)
averissimo Dec 10, 2024
015a964
Adds decorators to `tm_t_smq` (#1292)
averissimo Dec 10, 2024
d29d166
Adds decorators to `tm_t_shift_by_grade` (#1285)
averissimo Dec 10, 2024
ab0c15c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 10, 2024
8986e27
Adds decorators to `tm_t_summary_by` (#1294)
averissimo Dec 10, 2024
772c14b
Adds decorators to `tm_t_shift_by_arm` (#1287)
averissimo Dec 10, 2024
582ceb3
Adds decorators to `tm_t_shift_by_arm_by_worst` (#1286)
averissimo Dec 10, 2024
66e7b36
feat: pass qenv.error to module when template code fails
averissimo Dec 10, 2024
d403e95
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 10, 2024
d1d8df8
Introduce decorators for `tm_t_exposure` (#1279)
llrs-roche Dec 11, 2024
c146b11
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Dec 11, 2024
83d9fb0
Adds decorators to `tm_t_pp_laboratory` (#1291)
averissimo Dec 11, 2024
95f11f3
Adds decorators to `tm_t_pp_basic_info` (#1282)
averissimo Dec 11, 2024
b85523c
Adds decorators to `tm_t_pp_prior_medication` (#1288)
averissimo Dec 11, 2024
eb42bae
Introduce decorators for `tm_t events by grade` (#1276)
llrs-roche Dec 11, 2024
b2919f6
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Dec 11, 2024
5c90ece
docs: remove roxygen inline call
averissimo Dec 11, 2024
274d2b6
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 11, 2024
f439cd4
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Dec 11, 2024
00c8c0b
fix: linter error
averissimo Dec 11, 2024
a855989
Adds decorators to `tm_a_mmrm` (#1300)
averissimo Dec 12, 2024
0a06fbb
fix: tm_t_coxreg bug
averissimo Dec 12, 2024
6d4ce5b
fix: adverse events error
averissimo Dec 13, 2024
8a9edd2
Uses same code for source code generation in modules (#1301)
averissimo Dec 16, 2024
1db24ad
fix: remove rlang usage
averissimo Dec 17, 2024
19e8752
Decorators: Accepts new snapshot from `testthat::test()` (#1304)
averissimo Dec 17, 2024
9c4612c
fix: adds stats prefix
averissimo Dec 17, 2024
fad76cd
Merge branch 'main' into 1187_decorate_output@main
averissimo Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ repos:
- methods
- rlistings
- rmarkdown
- rtables
- scales
- shiny
- shinyjs
Expand All @@ -48,6 +47,9 @@ repos:
- insightsengineering/teal.widgets
- insightsengineering/tern.gee
- insightsengineering/tern.mmrm
- insightsengineering/rtables
- insightsengineering/rtables.officer
- insightsengineering/formatters
- utils
- vistime
- id: spell-check
Expand Down
15 changes: 15 additions & 0 deletions R/roxygen2_templates.R
m7pr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# nocov start
roxygen_decorators_param <- function(module_name) {
paste(
sep = " ",
lifecycle::badge("experimental"),
" (`list` of `teal_transform_module`, named `list` of `teal_transform_module` or",
"`NULL`) optional, if not `NULL`, decorator for tables or plots included in the module.",
"When a named list of `teal_transform_module`, the decorators are applied to the",
"respective output objects.\n\n",
"Otherwise, the decorators are applied to all objects, which is equivalent as using the name `default`.\n\n",
sprintf("See section \"Decorating `%s`\"", module_name),
"below for more details."
)
}
# nocov start
58 changes: 39 additions & 19 deletions R/tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ template_a_gee <- function(output_table,
if (output_table == "t_gee_cov") {
substitute(
expr = {
result_table <- tern.gee::as.rtable(model_fit, type = "cov")
subtitles(result_table) <- st
main_footer(result_table) <- mf
table <- tern.gee::as.rtable(model_fit, type = "cov")
subtitles(table) <- st
main_footer(table) <- mf
},
env = list(
st = basic_table_args$subtitles,
Expand All @@ -81,9 +81,9 @@ template_a_gee <- function(output_table,
} else if (output_table == "t_gee_coef") {
substitute(
expr = {
result_table <- tern.gee::as.rtable(data.frame(Coefficient = model_fit$coefficients))
subtitles(result_table) <- st
main_footer(result_table) <- mf
table <- tern.gee::as.rtable(data.frame(Coefficient = model_fit$coefficients))
subtitles(table) <- st
main_footer(table) <- mf
},
env = list(
conf_level = conf_level,
Expand All @@ -95,17 +95,16 @@ template_a_gee <- function(output_table,
substitute(
expr = {
lsmeans_fit_model <- tern.gee::lsmeans(model_fit, conf_level)
result_table <- rtables::basic_table(show_colcounts = TRUE) %>%
table <- rtables::basic_table(show_colcounts = TRUE) %>%
rtables::split_cols_by(var = input_arm_var, ref_group = model_fit$ref_level) %>%
tern.gee::summarize_gee_logistic() %>%
rtables::build_table(
df = lsmeans_fit_model,
alt_counts_df = dataname_lsmeans
)

subtitles(result_table) <- st
main_footer(result_table) <- mf
result_table
subtitles(table) <- st
main_footer(table) <- mf
},
env = list(
dataname_lsmeans = as.name(dataname_lsmeans),
Expand All @@ -132,9 +131,18 @@ template_a_gee <- function(output_table,
#' @inheritParams module_arguments
#' @inheritParams template_arguments
#' @inheritParams template_a_gee
#' @param decorators `r roxygen_decorators_param("tm_a_gee")`
#'
#' @inherit module_arguments return seealso
#'
#' @section Decorating `tm_a_gee`:
#'
#' This module generates the following objects, which can be modified in place using decorators:
#' - `table` (`ElementaryTable` - output of `rtables::build_table`)
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
Expand Down Expand Up @@ -200,7 +208,8 @@ tm_a_gee <- function(label,
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order = TRUE),
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()) {
basic_table_args = teal.widgets::basic_table_args(),
decorators = NULL) {
message("Initializing tm_a_gee (prototype)")

cov_var <- teal.transform::add_no_selected_choices(cov_var, multiple = TRUE)
Expand All @@ -218,6 +227,8 @@ tm_a_gee <- function(label,
checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(basic_table_args, "basic_table_args")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "table", null.ok = TRUE)

args <- as.list(environment())

Expand All @@ -243,7 +254,8 @@ tm_a_gee <- function(label,
parentname = parentname,
arm_ref_comp = arm_ref_comp,
label = label,
basic_table_args = basic_table_args
basic_table_args = basic_table_args,
decorators = decorators
)
),
datanames = teal.transform::get_extract_datanames(data_extract_list)
Expand Down Expand Up @@ -358,7 +370,8 @@ ui_gee <- function(id, ...) {
"Coefficients" = "t_gee_coef"
),
selected = "t_gee_lsmeans"
)
),
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(a$decorators, "table"))
),
forms = tagList(
teal.widgets::verbatim_popup_ui(ns("rcode"), button_label = "Show R code")
Expand All @@ -385,7 +398,8 @@ srv_gee <- function(id,
label,
plot_height,
plot_width,
basic_table_args) {
basic_table_args,
decorators) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
Expand Down Expand Up @@ -546,9 +560,15 @@ srv_gee <- function(id,
output_title
})

table_r <- reactive({
table_q()[["result_table"]]
})
decorated_table_q <- srv_decorate_teal_data(
id = "decorator",
data = table_q,
decorators = select_decorators(decorators, "table"),
expr = table
)

# Outputs to render.
table_r <- reactive(decorated_table_q()[["table"]])

teal.widgets::table_with_settings_srv(
id = "table",
Expand All @@ -558,7 +578,7 @@ srv_gee <- function(id,
# Render R code
teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(table_q())),
verbatim_content = reactive(teal.code::get_code(req(decorated_table_q()))),
title = label
)

Expand All @@ -582,7 +602,7 @@ srv_gee <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(table_q()))
card$append_src(teal.code::get_code(req(decorated_table_q())))
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
38 changes: 28 additions & 10 deletions R/tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@
#' @param x_facet (`data_extract_spec`)\cr row-wise faceting groups.
#' @param y_facet (`data_extract_spec`)\cr column-wise faceting groups.
#' @param plot_options (`list`)\cr list of plot options.
#' @param decorators `r roxygen_decorators_param("tm_g_barchart_simple")`
#'
#' @inherit module_arguments return seealso
#'
#' @section Decorating `tm_g_barchart_simple`:
#'
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`ggplot2`)
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
Expand Down Expand Up @@ -146,7 +155,8 @@ tm_g_barchart_simple <- function(x = NULL,
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
ggplot2_args = teal.widgets::ggplot2_args()) {
ggplot2_args = teal.widgets::ggplot2_args(),
decorators = NULL) {
message("Initializing tm_g_barchart_simple")
checkmate::assert_string(label)
checkmate::assert_list(plot_options, null.ok = TRUE)
Expand All @@ -171,6 +181,8 @@ tm_g_barchart_simple <- function(x = NULL,
checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(ggplot2_args, "ggplot2_args")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, names = "plot", null.ok = TRUE)

plot_options <- utils::modifyList(
list(stacked = FALSE), # default
Expand All @@ -190,7 +202,8 @@ tm_g_barchart_simple <- function(x = NULL,
y_facet = y_facet,
plot_height = plot_height,
plot_width = plot_width,
ggplot2_args = ggplot2_args
ggplot2_args = ggplot2_args,
decorators = decorators
),
datanames = "all"
)
Expand Down Expand Up @@ -249,6 +262,7 @@ ui_g_barchart_simple <- function(id, ...) {
is_single_dataset = is_single_dataset_value
)
},
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot")),
teal.widgets::panel_group(
teal.widgets::panel_item(
"Additional plot settings",
Expand Down Expand Up @@ -336,7 +350,8 @@ srv_g_barchart_simple <- function(id,
y_facet,
plot_height,
plot_width,
ggplot2_args) {
ggplot2_args,
decorators) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
Expand Down Expand Up @@ -506,13 +521,16 @@ srv_g_barchart_simple <- function(id,
)
)) %>%
teal.code::eval_code(code = plot_call)

# explicitly calling print on the plot inside the qenv evaluates
# the ggplot call and therefore catches errors
teal.code::eval_code(all_q, code = quote(print(plot)))
})

plot_r <- reactive(all_q()[["plot"]])
decorated_all_q_code <- srv_decorate_teal_data(
"decorator",
data = all_q,
decorators = select_decorators(decorators, "plot"),
expr = print(plot)
)

plot_r <- reactive(decorated_all_q_code()[["plot"]])

output$table <- renderTable({
req(iv_r()$is_valid())
Expand Down Expand Up @@ -550,7 +568,7 @@ srv_g_barchart_simple <- function(id,

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(all_q())),
verbatim_content = reactive(teal.code::get_code(req(decorated_all_q_code()))),
title = "Bar Chart"
)

Expand All @@ -569,7 +587,7 @@ srv_g_barchart_simple <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(all_q()))
card$append_src(teal.code::get_code(req(decorated_all_q_code())))
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
39 changes: 30 additions & 9 deletions R/tm_g_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ template_g_ci <- function(dataname,

substitute(
expr = {
gg <- graph_expr
print(gg)
plot <- graph_expr
},
env = list(graph_expr = pipe_expr(graph_list, pipe_str = "+"))
)
Expand All @@ -186,9 +185,18 @@ template_g_ci <- function(dataname,
#' @inheritParams module_arguments
#' @inheritParams template_g_ci
#' @param color (`data_extract_spec`)\cr the group variable used to determine the plot colors, shapes, and line types.
#' @param decorators `r roxygen_decorators_param("tm_g_ci")`
#'
#' @inherit module_arguments return seealso
#'
#' @section Decorating `tm_g_ci`:
#'
#' This module generates the following objects, which can be modified in place using decorators:
#' - `plot` (`ggplot2`)
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
#'
#' @examplesShinylive
#' library(teal.modules.clinical)
#' interactive <- function() TRUE
Expand Down Expand Up @@ -275,7 +283,8 @@ tm_g_ci <- function(label,
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
ggplot2_args = teal.widgets::ggplot2_args()) {
ggplot2_args = teal.widgets::ggplot2_args(),
decorators = NULL) {
message("Initializing tm_g_ci")
checkmate::assert_string(label)
stat <- match.arg(stat)
Expand All @@ -293,6 +302,8 @@ tm_g_ci <- function(label,
checkmate::assert_class(pre_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(post_output, classes = "shiny.tag", null.ok = TRUE)
checkmate::assert_class(ggplot2_args, "ggplot2_args")
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot", null.ok = TRUE)

args <- as.list(environment())

Expand All @@ -306,7 +317,8 @@ tm_g_ci <- function(label,
label = label,
plot_height = plot_height,
plot_width = plot_width,
ggplot2_args = ggplot2_args
ggplot2_args = ggplot2_args,
decorators = decorators
),
ui = ui_g_ci,
ui_args = args,
Expand Down Expand Up @@ -355,7 +367,8 @@ ui_g_ci <- function(id, ...) {
label = "Statistic to use",
choices = c("mean", "median"),
selected = args$stat
)
),
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot"))
),
forms = tagList(
teal.widgets::verbatim_popup_ui(ns("rcode"), "Show R code")
Expand All @@ -376,7 +389,8 @@ srv_g_ci <- function(id,
label,
plot_height,
plot_width,
ggplot2_args) {
ggplot2_args,
decorators) {
with_reporter <- !missing(reporter) && inherits(reporter, "Reporter")
with_filter <- !missing(filter_panel_api) && inherits(filter_panel_api, "FilterPanelAPI")
checkmate::assert_class(data, "reactive")
Expand Down Expand Up @@ -466,11 +480,18 @@ srv_g_ci <- function(id,
teal.code::eval_code(anl_q(), list_calls)
})

plot_r <- reactive(all_q()[["gg"]])
decorated_plot_q <- srv_decorate_teal_data(
id = "decorator",
data = all_q,
decorators = select_decorators(decorators, "plot"),
expr = print(plot)
)
# Outputs to render.
plot_r <- reactive(decorated_plot_q()[["plot"]])

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(all_q())),
verbatim_content = reactive(teal.code::get_code(req(decorated_plot_q()))),
title = label
)

Expand All @@ -497,7 +518,7 @@ srv_g_ci <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(all_q()))
card$append_src(teal.code::get_code(req(decorated_plot_q())))
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
Loading
Loading