From fd4327c3c5f806346d2a4c3cab75ac0ec2003df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 5 Nov 2024 18:36:45 +0000 Subject: [PATCH 1/3] feat: initial support for datanames() deprecation --- DESCRIPTION | 8 ++++---- R/tm_g_ae_oview.R | 7 +++---- R/tm_g_ae_sub.R | 3 +-- R/tm_g_butterfly.R | 3 +-- R/tm_g_events_term_id.R | 3 +-- R/tm_g_heat_bygrade.R | 9 ++++----- R/tm_g_patient_profile.R | 5 ++--- R/tm_g_spiderplot.R | 5 ++--- R/tm_g_swimlane.R | 9 ++++----- R/tm_g_waterfall.R | 5 ++--- man/tm_g_ae_oview.Rd | 7 +++---- man/tm_g_ae_sub.Rd | 3 +-- man/tm_g_butterfly.Rd | 3 +-- man/tm_g_events_term_id.Rd | 3 +-- man/tm_g_heat_bygrade.Rd | 9 ++++----- man/tm_g_patient_profile.Rd | 3 +-- man/tm_g_spiderplot.Rd | 3 +-- man/tm_g_swimlane.Rd | 3 +-- man/tm_g_waterfall.Rd | 3 +-- 19 files changed, 38 insertions(+), 56 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c9daebd2..e0582263 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,8 +24,8 @@ Depends: osprey (>= 0.1.16), R (>= 3.6), shiny (>= 1.6.0), - teal (>= 0.14.0.9027), - teal.transform (>= 0.4.0.9011) + teal (>= 0.15.2.9079), + teal.transform (>= 0.5.0.9015) Imports: checkmate (>= 2.1.0), dplyr (>= 1.0.5), @@ -33,8 +33,8 @@ Imports: ggplot2 (>= 3.4.0), lifecycle (>= 0.2.0), shinyvalidate, - teal.code (>= 0.4.1.9009), - teal.data (>= 0.3.0.9018), + teal.code (>= 0.5.0.9012), + teal.data (>= 0.6.0.9015), teal.logger (>= 0.2.0.9004), teal.reporter (>= 0.2.0), teal.widgets (>= 0.4.0), diff --git a/R/tm_g_ae_oview.R b/R/tm_g_ae_oview.R index bcb2a73f..7cf35d0a 100644 --- a/R/tm_g_ae_oview.R +++ b/R/tm_g_ae_oview.R @@ -20,7 +20,7 @@ #' within({ #' ADSL <- rADSL #' ADAE <- rADAE -#' add_event_flags <- function(dat) { +#' .add_event_flags <- function(dat) { #' dat <- dat |> #' mutate( #' TMPFL_SER = AESER == "Y", @@ -39,11 +39,10 @@ #' } #' dat #' } -#' ADAE <- add_event_flags(ADAE) +#' ADAE <- .add_event_flags(ADAE) #' }) #' -#' datanames(data) <- c("ADSL", "ADAE") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' ADAE <- data[["ADAE"]] #' diff --git a/R/tm_g_ae_sub.R b/R/tm_g_ae_sub.R index 37c7f523..099d46d0 100644 --- a/R/tm_g_ae_sub.R +++ b/R/tm_g_ae_sub.R @@ -24,8 +24,7 @@ #' ADAE <- rADAE #' }) #' -#' datanames(data) <- c("ADSL", "ADAE") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' app <- init( #' data = data, diff --git a/R/tm_g_butterfly.R b/R/tm_g_butterfly.R index c8bfe47f..d9651528 100644 --- a/R/tm_g_butterfly.R +++ b/R/tm_g_butterfly.R @@ -57,8 +57,7 @@ #' ) #' }) #' -#' datanames(data) <- c("ADSL", "ADAE") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' app <- init( #' data = data, diff --git a/R/tm_g_events_term_id.R b/R/tm_g_events_term_id.R index 98d67451..9a0ce0f2 100644 --- a/R/tm_g_events_term_id.R +++ b/R/tm_g_events_term_id.R @@ -24,8 +24,7 @@ #' ADAE <- rADAE #' }) #' -#' datanames(data) <- c("ADSL", "ADAE") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' app <- init( #' data = data, diff --git a/R/tm_g_heat_bygrade.R b/R/tm_g_heat_bygrade.R index ec423241..602bdc8f 100644 --- a/R/tm_g_heat_bygrade.R +++ b/R/tm_g_heat_bygrade.R @@ -46,7 +46,7 @@ #' select(-starts_with("ATC")) %>% #' unique() #' # function to derive AVISIT from ADEX -#' add_visit <- function(data_need_visit) { +#' .add_visit <- function(data_need_visit) { #' visit_dates <- ADEX %>% #' filter(PARAMCD == "DOSE") %>% #' distinct(USUBJID, AVISIT, ASTDTM) %>% @@ -63,16 +63,15 @@ #' return(data_visit) #' } #' # derive AVISIT for ADAE and ADCM -#' ADAE <- add_visit(ADAE) -#' ADCM <- add_visit(ADCM) +#' ADAE <- .add_visit(ADAE) +#' ADCM <- .add_visit(ADCM) #' # derive ongoing status variable for ADEX #' ADEX <- ADEX %>% #' filter(PARCAT1 == "INDIVIDUAL") %>% #' mutate(ongo_status = (EOSSTT == "ONGOING")) #' }) #' -#' datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' ADCM <- data[["ADCM"]] #' diff --git a/R/tm_g_patient_profile.R b/R/tm_g_patient_profile.R index 6f064abd..2f927cef 100644 --- a/R/tm_g_patient_profile.R +++ b/R/tm_g_patient_profile.R @@ -74,8 +74,7 @@ #' ADLB <- rADLB %>% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) #' }) #' -#' datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' ADSL <- data[["ADSL"]] #' @@ -367,7 +366,7 @@ srv_g_patient_profile <- function(id, vapply(checkboxes, function(x) x %in% input$select_ADaM, logical(1L)) ) - resolved <- teal.transform::resolve_delayed(patient_id, as.list(isolate(data())@env)) + resolved <- teal.transform::resolve_delayed(patient_id, as.list(isolate(data()))) updateSelectizeInput( session = session, diff --git a/R/tm_g_spiderplot.R b/R/tm_g_spiderplot.R index ac0495f5..ee7e7d01 100644 --- a/R/tm_g_spiderplot.R +++ b/R/tm_g_spiderplot.R @@ -32,8 +32,7 @@ #' ADTR <- rADTR #' }) #' -#' datanames(data) <- c("ADSL", "ADTR") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' app <- init( #' data = data, @@ -247,7 +246,7 @@ srv_g_spider <- function(id, data, filter_panel_api, paramcd, reporter, dataname moduleServer(id, function(input, output, session) { teal.logger::log_shiny_input_changes(input, namespace = "teal.osprey") - env <- as.list(isolate(data())@env) + env <- as.list(isolate(data())) resolved_paramcd <- teal.transform::resolve_delayed(paramcd, env) teal.widgets::updateOptionalSelectInput( diff --git a/R/tm_g_swimlane.R b/R/tm_g_swimlane.R index 55dcb42c..dc469a73 100644 --- a/R/tm_g_swimlane.R +++ b/R/tm_g_swimlane.R @@ -49,8 +49,7 @@ #' arrange(USUBJID) #' }) #' -#' datanames(data) <- c("ADSL", "ADRS") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' ADSL <- data[["ADSL"]] #' ADRS <- data[["ADRS"]] @@ -326,10 +325,10 @@ srv_g_swimlane <- function(id, output_q <- reactive({ teal::validate_inputs(iv()) - validate(need("ADSL" %in% teal.data::datanames(data()), "'ADSL' not included in data")) + validate(need("ADSL" %in% names(data()), "'ADSL' not included in data")) validate(need( - (length(teal.data::datanames(data())) == 1 && dataname == "ADSL") || - (length(teal.data::datanames(data())) >= 2 && dataname != "ADSL"), paste( + (length(names(data())) == 1 && dataname == "ADSL") || + (length(names(data())) >= 2 && dataname != "ADSL"), paste( "Please either add just 'ADSL' as dataname when just ADSL is available.", "In case 2 datasets are available ADSL is not supposed to be the dataname." ) diff --git a/R/tm_g_waterfall.R b/R/tm_g_waterfall.R index 5a5c7129..e91df91e 100644 --- a/R/tm_g_waterfall.R +++ b/R/tm_g_waterfall.R @@ -55,8 +55,7 @@ #' ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) #' }) #' -#' datanames(data) <- c("ADSL", "ADTR", "ADRS") -#' join_keys(data) <- default_cdisc_join_keys[datanames(data)] +#' join_keys(data) <- default_cdisc_join_keys[names(data)] #' #' app <- init( #' data = data, @@ -287,7 +286,7 @@ srv_g_waterfall <- function(id, moduleServer(id, function(input, output, session) { teal.logger::log_shiny_input_changes(input, namespace = "teal.osprey") - env <- as.list(isolate(data())@env) + env <- as.list(isolate(data())) resolved_bar_paramcd <- teal.transform::resolve_delayed(bar_paramcd, env) resolved_add_label_paramcd_rs <- teal.transform::resolve_delayed(add_label_paramcd_rs, env) resolved_anno_txt_paramcd_rs <- teal.transform::resolve_delayed(anno_txt_paramcd_rs, env) diff --git a/man/tm_g_ae_oview.Rd b/man/tm_g_ae_oview.Rd index 5c21df9d..5b5319a0 100644 --- a/man/tm_g_ae_oview.Rd +++ b/man/tm_g_ae_oview.Rd @@ -55,7 +55,7 @@ data <- teal_data() |> within({ ADSL <- rADSL ADAE <- rADAE - add_event_flags <- function(dat) { + .add_event_flags <- function(dat) { dat <- dat |> mutate( TMPFL_SER = AESER == "Y", @@ -74,11 +74,10 @@ data <- teal_data() |> } dat } - ADAE <- add_event_flags(ADAE) + ADAE <- .add_event_flags(ADAE) }) -datanames(data) <- c("ADSL", "ADAE") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] ADAE <- data[["ADAE"]] diff --git a/man/tm_g_ae_sub.Rd b/man/tm_g_ae_sub.Rd index 06b4cc4c..e1219bf7 100644 --- a/man/tm_g_ae_sub.Rd +++ b/man/tm_g_ae_sub.Rd @@ -56,8 +56,7 @@ data <- teal_data() |> ADAE <- rADAE }) -datanames(data) <- c("ADSL", "ADAE") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, diff --git a/man/tm_g_butterfly.Rd b/man/tm_g_butterfly.Rd index 4b25ab2b..de60e798 100644 --- a/man/tm_g_butterfly.Rd +++ b/man/tm_g_butterfly.Rd @@ -103,8 +103,7 @@ data <- teal_data() |> ) }) -datanames(data) <- c("ADSL", "ADAE") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, diff --git a/man/tm_g_events_term_id.Rd b/man/tm_g_events_term_id.Rd index 5a49b307..e3a81257 100644 --- a/man/tm_g_events_term_id.Rd +++ b/man/tm_g_events_term_id.Rd @@ -56,8 +56,7 @@ data <- teal_data() |> ADAE <- rADAE }) -datanames(data) <- c("ADSL", "ADAE") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, diff --git a/man/tm_g_heat_bygrade.Rd b/man/tm_g_heat_bygrade.Rd index 93057df0..712160ec 100644 --- a/man/tm_g_heat_bygrade.Rd +++ b/man/tm_g_heat_bygrade.Rd @@ -88,7 +88,7 @@ data <- teal_data() |> select(-starts_with("ATC")) \%>\% unique() # function to derive AVISIT from ADEX - add_visit <- function(data_need_visit) { + .add_visit <- function(data_need_visit) { visit_dates <- ADEX \%>\% filter(PARAMCD == "DOSE") \%>\% distinct(USUBJID, AVISIT, ASTDTM) \%>\% @@ -105,16 +105,15 @@ data <- teal_data() |> return(data_visit) } # derive AVISIT for ADAE and ADCM - ADAE <- add_visit(ADAE) - ADCM <- add_visit(ADCM) + ADAE <- .add_visit(ADAE) + ADCM <- .add_visit(ADCM) # derive ongoing status variable for ADEX ADEX <- ADEX \%>\% filter(PARCAT1 == "INDIVIDUAL") \%>\% mutate(ongo_status = (EOSSTT == "ONGOING")) }) -datanames(data) <- c("ADSL", "ADEX", "ADAE", "ADCM") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] ADCM <- data[["ADCM"]] diff --git a/man/tm_g_patient_profile.Rd b/man/tm_g_patient_profile.Rd index 393b0e2d..d47fbd37 100644 --- a/man/tm_g_patient_profile.Rd +++ b/man/tm_g_patient_profile.Rd @@ -122,8 +122,7 @@ data <- teal_data() |> ADLB <- rADLB \%>\% mutate(ADT = as.Date(ADTM), LBSTRESN = as.numeric(LBSTRESC)) }) -datanames(data) <- c("ADSL", "ADAE", "ADCM", "ADRS", "ADEX", "ADLB") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] diff --git a/man/tm_g_spiderplot.Rd b/man/tm_g_spiderplot.Rd index 35011035..9e2e51a1 100644 --- a/man/tm_g_spiderplot.Rd +++ b/man/tm_g_spiderplot.Rd @@ -84,8 +84,7 @@ data <- teal_data() |> ADTR <- rADTR }) -datanames(data) <- c("ADSL", "ADTR") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, diff --git a/man/tm_g_swimlane.Rd b/man/tm_g_swimlane.Rd index 6dd578b8..8a672d16 100644 --- a/man/tm_g_swimlane.Rd +++ b/man/tm_g_swimlane.Rd @@ -95,8 +95,7 @@ data <- teal_data() |> arrange(USUBJID) }) -datanames(data) <- c("ADSL", "ADRS") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] ADSL <- data[["ADSL"]] ADRS <- data[["ADRS"]] diff --git a/man/tm_g_waterfall.Rd b/man/tm_g_waterfall.Rd index a1ebdd12..41a18191 100644 --- a/man/tm_g_waterfall.Rd +++ b/man/tm_g_waterfall.Rd @@ -108,8 +108,7 @@ data <- teal_data() |> ADSL$SEX <- factor(ADSL$SEX, levels = unique(ADSL$SEX)) }) -datanames(data) <- c("ADSL", "ADTR", "ADRS") -join_keys(data) <- default_cdisc_join_keys[datanames(data)] +join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, From 45e8f1f67f8681ddb76c537de26b3836061b1013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 5 Nov 2024 18:56:53 +0000 Subject: [PATCH 2/3] fix: note on R CMD check --- R/zzz.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/zzz.R b/R/zzz.R index 09671e83..63121d55 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,4 +1,8 @@ .onLoad <- function(libname, pkgname) { + # Fixes R CMD check note on "All declared Imports should be used." + # teal.data is necessary to access S3 method names.teal_data + teal.data::teal_data + teal.logger::register_logger(namespace = "teal.osprey") teal.logger::register_handlers("teal.osprey") } From 387b7df4136b9c0f6941d04b1ccd6c5f07d0b184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:18:31 +0100 Subject: [PATCH 3/3] Update R/tm_g_swimlane.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dawid Kałędkowski Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com> --- R/tm_g_swimlane.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/tm_g_swimlane.R b/R/tm_g_swimlane.R index dc469a73..ff6564fe 100644 --- a/R/tm_g_swimlane.R +++ b/R/tm_g_swimlane.R @@ -327,8 +327,8 @@ srv_g_swimlane <- function(id, validate(need("ADSL" %in% names(data()), "'ADSL' not included in data")) validate(need( - (length(names(data())) == 1 && dataname == "ADSL") || - (length(names(data())) >= 2 && dataname != "ADSL"), paste( + (length(data()) == 1 && dataname == "ADSL") || + (length(data()) >= 2 && dataname != "ADSL"), paste( "Please either add just 'ADSL' as dataname when just ADSL is available.", "In case 2 datasets are available ADSL is not supposed to be the dataname." )