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

Add option to remove interval in tm_g_lineplot #840

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Updated `tm_t_coxreg` to drop factor covariate variable levels that are not present to avoid errors when filtering.
* Updated `tm_t_pp_basic_info`, `tm_t_pp_medical_history`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to print patient ID above table.
* Updated `tm_t_pp_basic_info`, `tm_g_pp_therapy`, `tm_g_pp_adverse_events`, and `tm_t_pp_laboratory` to use `rlistings` to print data neatly in reports.
* Updated `tm_g_lineplot` to allow user to remove interval from plot.


### Bug fixes
Expand Down
36 changes: 22 additions & 14 deletions R/tm_g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ template_g_lineplot <- function(dataname = "ANL",
user_plot = ggplot2_args,
module_plot = teal.widgets::ggplot2_args(
labs = list(
title = sprintf(
"Plot of %s and %s %s of %s by Visit",
names(which(mid_choices == mid)),
`if`(interval %in% c("mean_ci", "median_ci"), paste0(conf_level * 100, "%"), ""),
names(which(interval_choices == interval)),
y
title = paste0(
"Plot of ", names(which(mid_choices == mid)),
if (!is.null(interval)) {
paste0(
" and ",
if (interval %in% c("mean_ci", "median_ci")) paste0(conf_level * 100, "% "),
names(which(interval_choices == interval))
)
},
" of ", y, " by Visit"
),
subtitle = "",
y = sprintf("%s %s Values for", y, names(which(mid_choices == mid)))
Expand Down Expand Up @@ -291,7 +295,7 @@ tm_g_lineplot <- function(label,
checkmate::assert_string(dataname)
checkmate::assert_string(parentname)
checkmate::assert_string(mid)
checkmate::assert_string(interval)
checkmate::assert_string(interval, null.ok = TRUE)
whiskers <- match.arg(whiskers)
checkmate::assert_class(conf_level, "choices_selected")
checkmate::assert_numeric(plot_height, len = 3, any.missing = FALSE, finite = TRUE)
Expand Down Expand Up @@ -432,8 +436,8 @@ ui_g_lineplot <- function(id, ...) {
shiny::checkboxGroupInput(
ns("whiskers"),
"Whiskers to display",
choices = c("Lower", "Upper"),
selected = c("Lower", "Upper")
choices = c("Upper", "Lower"),
selected = c("Upper", "Lower")
),
shiny::radioButtons(
ns("mid_type"),
Expand Down Expand Up @@ -542,8 +546,6 @@ srv_g_lineplot <- function(id,
message_fmt = "Please choose a confidence level between 0 and 1", inclusive = c(FALSE, FALSE)
)
)
iv$add_rule("interval", shinyvalidate::sv_required("Please select an interval for the midpoint statistic"))
iv$add_rule("whiskers", shinyvalidate::sv_required("At least one of the whiskers must be selected"))
teal.transform::compose_and_enable_validators(iv, selector_list)
})

Expand Down Expand Up @@ -597,9 +599,15 @@ srv_g_lineplot <- function(id,
ANL <- merged$anl_q()[["ANL"]] # nolint
teal::validate_has_data(ANL, 2)

whiskers_selected <- ifelse(input$whiskers == "Lower", 1, ifelse(input$whiskers == "Upper", 2, 1:2))
input_whiskers <- names(tern::s_summary(0)[[input$interval]][whiskers_selected])
input_interval <- input$interval
whiskers_selected <- if ("Lower" %in% input$whiskers) 1 else NULL
if ("Upper" %in% input$whiskers) whiskers_selected <- c(whiskers_selected, 2)
if (is.null(input$interval) || is.null(whiskers_selected)) {
input_whiskers <- NULL
input_interval <- NULL
} else {
input_interval <- input$interval
input_whiskers <- names(tern::s_summary(0)[[input_interval]][whiskers_selected])
}
input_param <- as.character(unique(ANL[[names(merged$anl_input_r()$columns_source$param)[1]]]))

my_calls <- template_g_lineplot(
Expand Down
10 changes: 6 additions & 4 deletions man/template_g_lineplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions man/tm_g_lineplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.