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
…mes()` (#288)

# Pull Request

Part of insightsengineering/teal.data#333

Blocked by:

- insightsengineering/teal.code#218
- insightsengineering/teal.data#347
- insightsengineering/teal#1402

---------

Signed-off-by: André Veríssimo <[email protected]>
Co-authored-by: Dawid Kałędkowski <[email protected]>
  • Loading branch information
averissimo and gogonzo authored Nov 8, 2024
1 parent 5c1f2c3 commit 8ae4bfd
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 56 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ 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),
formatters (>= 0.3.1),
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),
Expand Down
7 changes: 3 additions & 4 deletions R/tm_g_ae_oview.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"]]
#'
Expand Down
3 changes: 1 addition & 2 deletions R/tm_g_ae_sub.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions R/tm_g_butterfly.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions R/tm_g_events_term_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 4 additions & 5 deletions R/tm_g_heat_bygrade.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>%
Expand All @@ -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"]]
#'
Expand Down
5 changes: 2 additions & 3 deletions R/tm_g_patient_profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
#'
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions R/tm_g_spiderplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 4 additions & 5 deletions R/tm_g_swimlane.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
Expand Down Expand Up @@ -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(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."
)
Expand Down
5 changes: 2 additions & 3 deletions R/tm_g_waterfall.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -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")
}
7 changes: 3 additions & 4 deletions man/tm_g_ae_oview.Rd

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

3 changes: 1 addition & 2 deletions man/tm_g_ae_sub.Rd

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

3 changes: 1 addition & 2 deletions man/tm_g_butterfly.Rd

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

3 changes: 1 addition & 2 deletions man/tm_g_events_term_id.Rd

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

9 changes: 4 additions & 5 deletions man/tm_g_heat_bygrade.Rd

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

3 changes: 1 addition & 2 deletions man/tm_g_patient_profile.Rd

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

3 changes: 1 addition & 2 deletions man/tm_g_spiderplot.Rd

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

3 changes: 1 addition & 2 deletions man/tm_g_swimlane.Rd

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

3 changes: 1 addition & 2 deletions man/tm_g_waterfall.Rd

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

0 comments on commit 8ae4bfd

Please sign in to comment.