Skip to content

Commit f5a741a

Browse files
committed
fix: R CMD check errors and adds lifecycle to dependencies
1 parent 737fe42 commit f5a741a

File tree

6 files changed

+24
-26
lines changed

6 files changed

+24
-26
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Imports:
3535
DT (>= 0.13),
3636
forcats (>= 1.0.0),
3737
grid,
38+
lifecycle (>= 0.2.0),
3839
scales,
3940
shinyjs,
4041
shinyTree (>= 0.2.8),
@@ -84,7 +85,7 @@ VignetteBuilder:
8485
Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2,
8586
rstudio/shiny, insightsengineering/teal,
8687
insightsengineering/teal.transform, mllg/checkmate, tidyverse/dplyr,
87-
rstudio/DT, tidyverse/forcats, r-lib/scales, daattali/shinyjs,
88+
rstudio/DT, tidyverse/forcats, r-lib/lifecycle, r-lib/scales, daattali/shinyjs,
8889
shinyTree/shinyTree, rstudio/shinyvalidate, dreamRs/shinyWidgets,
8990
tidyverse/stringr, insightsengineering/teal.code,
9091
insightsengineering/teal.data, insightsengineering/teal.logger,

R/tm_a_regression.R

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ tm_a_regression <- function(label = "Regression Analysis",
225225
.var.name = "label_segment_threshold"
226226
)
227227
}
228+
decorators <- normalize_decorators(decorators)
229+
assert_decorators(decorators, "plot", null.ok = TRUE)
228230
# End of assertions
229231

230232
# Make UI args
@@ -319,7 +321,7 @@ ui_a_regression <- function(id, ...) {
319321
label = "Outlier label"
320322
)
321323
),
322-
ui_transform_teal_data(ns("decorate"), transformators = args$decorators),
324+
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot")),
323325
teal.widgets::panel_group(
324326
teal.widgets::panel_item(
325327
title = "Plot settings",
@@ -582,22 +584,15 @@ srv_a_regression <- function(id,
582584
shinyjs::show("size")
583585
shinyjs::show("alpha")
584586
plot <- substitute(
587+
expr = ggplot(fit$model[, 2:1], aes_string(regressor, response)) +
588+
geom_point(size = size, alpha = alpha) +
589+
stat_smooth(method = "lm", formula = y ~ x, se = FALSE),
585590
env = list(
586591
regressor = regression_var()$regressor,
587592
response = regression_var()$response,
588593
size = input$size,
589594
alpha = input$alpha
590-
),
591-
expr = ggplot(
592-
fit$model[, 2:1],
593-
aes_string(regressor, response)
594-
) +
595-
geom_point(size = size, alpha = alpha) +
596-
stat_smooth(
597-
method = "lm",
598-
formula = y ~ x,
599-
se = FALSE
600-
)
595+
)
601596
)
602597
if (input$show_outlier) {
603598
plot <- substitute(
@@ -979,12 +974,16 @@ srv_a_regression <- function(id,
979974
)
980975
})
981976

982-
decorated_output_q_no_print <- srv_transform_teal_data("decorate", data = output_q, transformators = decorators)
983-
decorated_output_q <- reactive(within(decorated_output_q_no_print(), expr = print(plot)))
977+
decorated_output_q <- srv_decorate_teal_data(
978+
"decorator",
979+
data = output_q,
980+
decorators = select_decorators(decorators, "plot"),
981+
expr = print(plot)
982+
)
984983

985984
fitted <- reactive({
986985
req(output_q())
987-
decorated_output_q_no_print()[["fit"]]
986+
decorated_output_q()[["fit"]]
988987
})
989988
plot_r <- reactive({
990989
req(output_q())

R/tm_g_association.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ tm_g_association <- function(label = "Association",
178178

179179
decorators <- normalize_decorators(decorators)
180180
assert_decorators(decorators, null.ok = TRUE, "plot")
181-
182181
# End of assertions
183182

184183
# Make UI args
@@ -529,7 +528,7 @@ srv_tm_g_association <- function(id,
529528

530529
teal.widgets::verbatim_popup_srv(
531530
id = "rcode",
532-
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
531+
verbatim_content = reactive(teal.code::get_code(req(decorated_output_grob_q()))),
533532
title = "Association Plot"
534533
)
535534

@@ -548,7 +547,7 @@ srv_tm_g_association <- function(id,
548547
card$append_text("Comment", "header3")
549548
card$append_text(comment)
550549
}
551-
card$append_src(teal.code::get_code(req(decorated_output_q())))
550+
card$append_src(teal.code::get_code(req(decorated_output_grob_q())))
552551
card
553552
}
554553
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)

R/tm_missing_data.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,20 +923,19 @@ srv_missing_data <- function(id,
923923
)
924924
)
925925
}
926-
expr <- if (isTRUE(input$if_patients_plot)) {
927-
quote({
926+
if (isTRUE(input$if_patients_plot)) {
927+
teal.code::eval_code(qenv, {
928928
g1 <- ggplotGrob(summary_plot_top)
929929
g2 <- ggplotGrob(summary_plot_bottom)
930930
summary_plot <- gridExtra::gtable_cbind(g1, g2, size = "first")
931931
summary_plot$heights <- grid::unit.pmax(g1$heights, g2$heights)
932932
})
933933
} else {
934-
quote({
934+
teal.code::eval_code(qenv, {
935935
g1 <- ggplotGrob(summary_plot_top)
936936
summary_plot <- g1
937937
})
938938
}
939-
teal.code::eval_code(qenv, expr)
940939
})
941940

942941
combination_plot_q <- reactive({

R/tm_outliers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
13231323
}
13241324
card$append_text("Plot", "header3")
13251325
if (tab_type == "Boxplot") {
1326-
card$append_plot(boxplot_r(), dim = box_pws$dim())
1326+
card$append_plot(box_plot_r(), dim = box_pws$dim())
13271327
} else if (tab_type == "Density Plot") {
13281328
card$append_plot(density_plot_r(), dim = density_pws$dim())
13291329
} else if (tab_type == "Cumulative Distribution Plot") {

R/utils.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ srv_decorate_teal_data <- function(id, data, decorators, expr, expr_is_reactive
311311
if (missing_expr) {
312312
decorated_output()
313313
} else if (expr_is_reactive) {
314-
eval_code(decorated_output(), expr())
314+
teal.code::eval_code(decorated_output(), expr())
315315
} else {
316-
eval_code(decorated_output(), expr)
316+
teal.code::eval_code(decorated_output(), expr)
317317
}
318318
})
319319
})

0 commit comments

Comments
 (0)