Skip to content

Commit

Permalink
fix: R CMD check errors and adds lifecycle to dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Nov 29, 2024
1 parent 737fe42 commit f5a741a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Imports:
DT (>= 0.13),
forcats (>= 1.0.0),
grid,
lifecycle (>= 0.2.0),
scales,
shinyjs,
shinyTree (>= 0.2.8),
Expand Down Expand Up @@ -84,7 +85,7 @@ VignetteBuilder:
Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2,
rstudio/shiny, insightsengineering/teal,
insightsengineering/teal.transform, mllg/checkmate, tidyverse/dplyr,
rstudio/DT, tidyverse/forcats, r-lib/scales, daattali/shinyjs,
rstudio/DT, tidyverse/forcats, r-lib/lifecycle, r-lib/scales, daattali/shinyjs,
shinyTree/shinyTree, rstudio/shinyvalidate, dreamRs/shinyWidgets,
tidyverse/stringr, insightsengineering/teal.code,
insightsengineering/teal.data, insightsengineering/teal.logger,
Expand Down
29 changes: 14 additions & 15 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ tm_a_regression <- function(label = "Regression Analysis",
.var.name = "label_segment_threshold"
)
}
decorators <- normalize_decorators(decorators)
assert_decorators(decorators, "plot", null.ok = TRUE)
# End of assertions

# Make UI args
Expand Down Expand Up @@ -319,7 +321,7 @@ ui_a_regression <- function(id, ...) {
label = "Outlier label"
)
),
ui_transform_teal_data(ns("decorate"), transformators = args$decorators),
ui_decorate_teal_data(ns("decorator"), decorators = select_decorators(args$decorators, "plot")),
teal.widgets::panel_group(
teal.widgets::panel_item(
title = "Plot settings",
Expand Down Expand Up @@ -582,22 +584,15 @@ srv_a_regression <- function(id,
shinyjs::show("size")
shinyjs::show("alpha")
plot <- substitute(
expr = ggplot(fit$model[, 2:1], aes_string(regressor, response)) +
geom_point(size = size, alpha = alpha) +
stat_smooth(method = "lm", formula = y ~ x, se = FALSE),
env = list(
regressor = regression_var()$regressor,
response = regression_var()$response,
size = input$size,
alpha = input$alpha
),
expr = ggplot(
fit$model[, 2:1],
aes_string(regressor, response)
) +
geom_point(size = size, alpha = alpha) +
stat_smooth(
method = "lm",
formula = y ~ x,
se = FALSE
)
)
)
if (input$show_outlier) {
plot <- substitute(
Expand Down Expand Up @@ -979,12 +974,16 @@ srv_a_regression <- function(id,
)
})

decorated_output_q_no_print <- srv_transform_teal_data("decorate", data = output_q, transformators = decorators)
decorated_output_q <- reactive(within(decorated_output_q_no_print(), expr = print(plot)))
decorated_output_q <- srv_decorate_teal_data(
"decorator",
data = output_q,
decorators = select_decorators(decorators, "plot"),
expr = print(plot)
)

fitted <- reactive({
req(output_q())
decorated_output_q_no_print()[["fit"]]
decorated_output_q()[["fit"]]
})
plot_r <- reactive({
req(output_q())
Expand Down
5 changes: 2 additions & 3 deletions R/tm_g_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ tm_g_association <- function(label = "Association",

decorators <- normalize_decorators(decorators)
assert_decorators(decorators, null.ok = TRUE, "plot")

# End of assertions

# Make UI args
Expand Down Expand Up @@ -529,7 +528,7 @@ srv_tm_g_association <- function(id,

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
verbatim_content = reactive(teal.code::get_code(req(decorated_output_grob_q()))),
title = "Association Plot"
)

Expand All @@ -548,7 +547,7 @@ srv_tm_g_association <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_q())))
card$append_src(teal.code::get_code(req(decorated_output_grob_q())))
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 3 additions & 4 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -923,20 +923,19 @@ srv_missing_data <- function(id,
)
)
}
expr <- if (isTRUE(input$if_patients_plot)) {
quote({
if (isTRUE(input$if_patients_plot)) {
teal.code::eval_code(qenv, {
g1 <- ggplotGrob(summary_plot_top)
g2 <- ggplotGrob(summary_plot_bottom)
summary_plot <- gridExtra::gtable_cbind(g1, g2, size = "first")
summary_plot$heights <- grid::unit.pmax(g1$heights, g2$heights)
})
} else {
quote({
teal.code::eval_code(qenv, {
g1 <- ggplotGrob(summary_plot_top)
summary_plot <- g1
})
}
teal.code::eval_code(qenv, expr)
})

combination_plot_q <- reactive({
Expand Down
2 changes: 1 addition & 1 deletion R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
}
card$append_text("Plot", "header3")
if (tab_type == "Boxplot") {
card$append_plot(boxplot_r(), dim = box_pws$dim())
card$append_plot(box_plot_r(), dim = box_pws$dim())
} else if (tab_type == "Density Plot") {
card$append_plot(density_plot_r(), dim = density_pws$dim())
} else if (tab_type == "Cumulative Distribution Plot") {
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ srv_decorate_teal_data <- function(id, data, decorators, expr, expr_is_reactive
if (missing_expr) {
decorated_output()
} else if (expr_is_reactive) {
eval_code(decorated_output(), expr())
teal.code::eval_code(decorated_output(), expr())
} else {
eval_code(decorated_output(), expr)
teal.code::eval_code(decorated_output(), expr)
}
})
})
Expand Down

0 comments on commit f5a741a

Please sign in to comment.