Skip to content

Commit

Permalink
teal.data::datanames() is deprecated in favor of dot-prefix and `na…
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo authored Nov 8, 2024
1 parent d153e8d commit 4063d5a
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 152 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Depends:
goshawk (>= 0.1.18),
R (>= 3.6),
shiny (>= 1.6.0),
teal (>= 0.15.2),
teal.transform (>= 0.5.0)
teal (>= 0.15.2.9079),
teal.transform (>= 0.5.0.9015)
Imports:
checkmate (>= 2.1.0),
colourpicker,
Expand All @@ -47,7 +47,7 @@ Imports:
shinyjs,
shinyvalidate,
stats,
teal.code (>= 0.5.0),
teal.code (>= 0.5.0.9012),
teal.logger (>= 0.2.0.9011),
teal.reporter (>= 0.2.0),
teal.widgets (>= 0.4.0)
Expand All @@ -58,7 +58,7 @@ Suggests:
rvest (>= 1.0.0),
shinytest2,
stringr (>= 1.4.1),
teal.data (>= 0.5.0),
teal.data (>= 0.6.0.9015),
tern (>= 0.7.10),
testthat (>= 3.0.4),
utils
Expand Down
25 changes: 11 additions & 14 deletions R/tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@
#' library(stringr)
#'
#' # use non-exported function from goshawk
#' h_identify_loq_values <- getFromNamespace("h_identify_loq_values", "goshawk")
#' .h_identify_loq_values <- getFromNamespace("h_identify_loq_values", "goshawk")
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' .arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#' set.seed(1)
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' .var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' mutate(
#' AVISITCD = case_when(
Expand All @@ -86,9 +86,9 @@
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
#' ),
#' ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
#' ARM = as.character(.arm_mapping[match(ARM, names(.arm_mapping))]),
#' ARM = factor(ARM) %>% reorder(TRTORD),
#' ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
#' ACTARM = as.character(.arm_mapping[match(ACTARM, names(.arm_mapping))]),
#' ACTARM = factor(ACTARM) %>% reorder(TRTORD),
#' ANRLO = 50,
#' ANRHI = 75
Expand All @@ -105,20 +105,17 @@
#' )) %>%
#' ungroup()
#'
#' attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]]
#' attr(ADLB[["ARM"]], "label") <- .var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- .var_labels[["ACTARM"]]
#' attr(ADLB[["ANRLO"]], "label") <- "Analysis Normal Range Lower Limit"
#' attr(ADLB[["ANRHI"]], "label") <- "Analysis Normal Range Upper Limit"
#'
#' # add LLOQ and ULOQ variables
#' ALB_LOQS <- h_identify_loq_values(ADLB, "LOQFL")
#' ALB_LOQS <- .h_identify_loq_values(ADLB, "LOQFL")
#' ADLB <- left_join(ADLB, ALB_LOQS, by = "PARAM")
#' })
#'
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#'
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
#' app <- init(
#' data = data,
Expand Down Expand Up @@ -308,7 +305,7 @@ srv_g_boxplot <- function(id,
moduleServer(id, function(input, output, session) {
teal.logger::log_shiny_input_changes(input, namespace = "teal.goshawk")
output$axis_selections <- renderUI({
env <- shiny::isolate(as.list(data()@env))
env <- shiny::isolate(as.list(data()))
resolved_x <- teal.transform::resolve_delayed(module_args$xaxis_var, env)
resolved_y <- teal.transform::resolve_delayed(module_args$yaxis_var, env)
resolved_param <- teal.transform::resolve_delayed(module_args$param, env)
Expand Down Expand Up @@ -508,7 +505,7 @@ srv_g_boxplot <- function(id,

joined_qenvs <- reactive({
req(create_plot(), create_table())
teal.code::join(create_plot(), create_table())
c(create_plot(), create_table())
})

code <- reactive(teal.code::get_code(joined_qenvs()))
Expand Down
23 changes: 10 additions & 13 deletions R/tm_g_gh_correlationplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@
#' library(stringr)
#'
#' # use non-exported function from goshawk
#' h_identify_loq_values <- getFromNamespace("h_identify_loq_values", "goshawk")
#' .h_identify_loq_values <- getFromNamespace("h_identify_loq_values", "goshawk")
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' .arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#' color_manual <- c("150mg QD" = "#000000", "Placebo" = "#3498DB", "Combination" = "#E74C3C")
#' .color_manual <- c("150mg QD" = "#000000", "Placebo" = "#3498DB", "Combination" = "#E74C3C")
#' # assign LOQ flag symbols: circles for "N" and triangles for "Y", squares for "NA"
#' shape_manual <- c("N" = 1, "Y" = 2, "NA" = 0)
#' .shape_manual <- c("N" = 1, "Y" = 2, "NA" = 0)
#'
#' set.seed(1)
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' .var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' mutate(AVISITCD = case_when(
#' AVISIT == "SCREENING" ~ "SCR",
Expand Down Expand Up @@ -102,7 +102,7 @@
#' ifelse(grepl("A", ARMCD), 3, NA)
#' )
#' )) %>%
#' mutate(ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))])) %>%
#' mutate(ARM = as.character(.arm_mapping[match(ARM, names(.arm_mapping))])) %>%
#' mutate(ARM = factor(ARM) %>%
#' reorder(TRTORD)) %>%
#' mutate(
Expand Down Expand Up @@ -130,19 +130,16 @@
#' paste(">", round(runif(1, min = 70, max = 75))), LBSTRESC
#' )) %>%
#' ungroup()
#' attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
#' attr(ADLB[["ARM"]], "label") <- .var_labels[["ARM"]]
#' attr(ADLB[["ANRHI"]], "label") <- "Analysis Normal Range Upper Limit"
#' attr(ADLB[["ANRLO"]], "label") <- "Analysis Normal Range Lower Limit"
#'
#' # add LLOQ and ULOQ variables
#' ADLB_LOQS <- h_identify_loq_values(ADLB, "LOQFL")
#' ADLB_LOQS <- .h_identify_loq_values(ADLB, "LOQFL")
#' ADLB <- left_join(ADLB, ADLB_LOQS, by = "PARAM")
#' })
#'
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#'
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
#' app <- init(
#' data = data,
Expand Down Expand Up @@ -374,7 +371,7 @@ srv_g_correlationplot <- function(id,
moduleServer(id, function(input, output, session) {
teal.logger::log_shiny_input_changes(input, namespace = "teal.goshawk")
output$axis_selections <- renderUI({
env <- shiny::isolate(as.list(data()@env))
env <- shiny::isolate(as.list(data()))
resolved_x_param <- teal.transform::resolve_delayed(module_args$xaxis_param, env)
resolved_x_var <- teal.transform::resolve_delayed(module_args$xaxis_var, env)
resolved_y_param <- teal.transform::resolve_delayed(module_args$yaxis_param, env)
Expand Down
20 changes: 9 additions & 11 deletions R/tm_g_gh_density_distribution_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
#' library(stringr)
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' .arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' .var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' mutate(
#' AVISITCD = case_when(
Expand All @@ -68,19 +68,17 @@
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
#' ),
#' ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
#' ARM = as.character(.arm_mapping[match(ARM, names(.arm_mapping))]),
#' ARM = factor(ARM) %>% reorder(TRTORD),
#' ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
#' ACTARM = as.character(.arm_mapping[match(ACTARM, names(.arm_mapping))]),
#' ACTARM = factor(ACTARM) %>% reorder(TRTORD)
#' )
#'
#' attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]]
#' attr(ADLB[["ARM"]], "label") <- .var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- .var_labels[["ACTARM"]]
#' })
#'
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
#' app <- init(
#' data = data,
Expand Down Expand Up @@ -256,7 +254,7 @@ srv_g_density_distribution_plot <- function(id, # nolint
moduleServer(id, function(input, output, session) {
teal.logger::log_shiny_input_changes(input, namespace = "teal.goshawk")
output$axis_selections <- renderUI({
env <- shiny::isolate(as.list(data()@env))
env <- shiny::isolate(as.list(data()))
resolved_x <- teal.transform::resolve_delayed(module_args$xaxis_var, env)
resolved_param <- teal.transform::resolve_delayed(module_args$param, env)
resolved_trt <- teal.transform::resolve_delayed(module_args$trt_group, env)
Expand Down Expand Up @@ -416,7 +414,7 @@ srv_g_density_distribution_plot <- function(id, # nolint

joined_qenvs <- reactive({
req(create_plot(), create_table())
teal.code::join(create_plot(), create_table())
c(create_plot(), create_table())
})

code <- reactive(teal.code::get_code(joined_qenvs()))
Expand Down
18 changes: 8 additions & 10 deletions R/tm_g_gh_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@
#' library(nestcolor)
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' .arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#'
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' .var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' mutate(
#' AVISITCD = case_when(
Expand All @@ -89,18 +89,16 @@
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
#' ),
#' ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
#' ARM = as.character(.arm_mapping[match(ARM, names(.arm_mapping))]),
#' ARM = factor(ARM) %>% reorder(TRTORD),
#' ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
#' ACTARM = as.character(.arm_mapping[match(ACTARM, names(.arm_mapping))]),
#' ACTARM = factor(ACTARM) %>% reorder(TRTORD)
#' )
#' attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]]
#' attr(ADLB[["ARM"]], "label") <- .var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- .var_labels[["ACTARM"]]
#' })
#'
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
#' app <- init(
#' data = data,
Expand Down Expand Up @@ -349,7 +347,7 @@ srv_lineplot <- function(id,
ns <- session$ns

output$axis_selections <- renderUI({
env <- shiny::isolate(as.list(data()@env))
env <- shiny::isolate(as.list(data()))
resolved_x <- teal.transform::resolve_delayed(module_args$xaxis_var, env)
resolved_y <- teal.transform::resolve_delayed(module_args$yaxis_var, env)
resolved_param <- teal.transform::resolve_delayed(module_args$param, env)
Expand Down
18 changes: 8 additions & 10 deletions R/tm_g_gh_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
#' library(stringr)
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' .arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#'
#' ADSL <- rADSL
#' ADLB <- rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' .var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' mutate(
#' AVISITCD = case_when(
Expand All @@ -74,18 +74,16 @@
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
#' ),
#' ARM = as.character(arm_mapping[match(ARM, names(arm_mapping))]),
#' ARM = as.character(.arm_mapping[match(ARM, names(.arm_mapping))]),
#' ARM = factor(ARM) %>% reorder(TRTORD),
#' ACTARM = as.character(arm_mapping[match(ACTARM, names(arm_mapping))]),
#' ACTARM = as.character(.arm_mapping[match(ACTARM, names(.arm_mapping))]),
#' ACTARM = factor(ACTARM) %>% reorder(TRTORD)
#' )
#' attr(ADLB[["ARM"]], "label") <- var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- var_labels[["ACTARM"]]
#' attr(ADLB[["ARM"]], "label") <- .var_labels[["ARM"]]
#' attr(ADLB[["ACTARM"]], "label") <- .var_labels[["ACTARM"]]
#' })
#'
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#' join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
#'
#' app <- init(
Expand Down Expand Up @@ -257,7 +255,7 @@ srv_g_scatterplot <- function(id,
moduleServer(id, function(input, output, session) {
teal.logger::log_shiny_input_changes(input, namespace = "teal.goshawk")
output$axis_selections <- renderUI({
env <- shiny::isolate(as.list(data()@env))
env <- shiny::isolate(as.list(data()))
resolved_x <- teal.transform::resolve_delayed(module_args$xaxis_var, env)
resolved_y <- teal.transform::resolve_delayed(module_args$yaxis_var, env)
resolved_param <- teal.transform::resolve_delayed(module_args$param, env)
Expand Down
Loading

0 comments on commit 4063d5a

Please sign in to comment.