Skip to content

Commit

Permalink
Update docs to use the new teal_data instead of TealData (#245)
Browse files Browse the repository at this point in the history
fixes #243
part of
insightsengineering/nestdevs-tasks#41
insightsengineering/teal.data#184


- [x]  add the news section for change.
- [x]  update the examples in the documentation to pass teal_data.
- [x] update join_keys calls once the pull request is completed at
insightsengineering/teal.data#184.
- [x]  Revise and update the vignettes accordingly.
- [ ] make version bump once
insightsengineering/teal.data#184. is merged.

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: vedhav <vedhaviyash4@gmail.com>
  • Loading branch information
4 people authored Nov 20, 2023
1 parent 348f38e commit bd74b80
Show file tree
Hide file tree
Showing 15 changed files with 734 additions and 1,169 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Depends:
goshawk (>= 0.1.15),
R (>= 3.6),
shiny,
teal (>= 0.14.0)
teal (>= 0.14.0.9019)
Imports:
checkmate,
colourpicker,
Expand All @@ -47,15 +47,15 @@ Imports:
teal.code (>= 0.4.0),
teal.logger (>= 0.1.1),
teal.reporter (>= 0.2.0),
teal.transform (>= 0.4.0),
teal.transform (>= 0.4.0.9007),
teal.widgets (>= 0.4.0),
tidyr
Suggests:
knitr,
nestcolor (>= 0.1.0),
rmarkdown,
stringr,
teal.data (>= 0.3.0),
teal.data (>= 0.3.0.9010),
tern (>= 0.7.10),
testthat (>= 2.0),
utils
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# teal.goshawk 0.1.15.9002

### Enhancements

* Updated the documentation and vignettes to demonstrate method to pass `teal_data` object to `teal::init()`.

# teal.goshawk 0.1.15

### Enhancements
Expand Down
172 changes: 64 additions & 108 deletions R/tm_g_gh_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,121 +48,77 @@
#' @examples
#'
#' # Example using ADaM structure analysis dataset.
#' data <- teal_data()
#' data <- within(data, {
#' library(dplyr)
#' library(nestcolor)
#'
#' library(dplyr)
#' library(nestcolor)
#' # original ARM value = dose value
#' arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#' set.seed(1)
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
#' AVISITCD = dplyr::case_when(
#' AVISIT == "SCREENING" ~ "SCR",
#' AVISIT == "BASELINE" ~ "BL",
#' grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' TRUE ~ as.character(NA)
#' ),
#' AVISITCDN = dplyr::case_when(
#' AVISITCD == "SCR" ~ -2,
#' AVISITCD == "BL" ~ 0,
#' grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
#' TRUE ~ as.numeric(NA)
#' ),
#' AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
#' TRTORD = dplyr::case_when(
#' ARMCD == "ARM C" ~ 1,
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
#' ),
#' 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 = factor(ACTARM) %>% reorder(TRTORD),
#' ANRLO = 50,
#' ANRHI = 75
#' ) %>%
#' dplyr::rowwise() %>%
#' dplyr::group_by(PARAMCD) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste("<", round(runif(1, min = 25, max = 30))), LBSTRESC
#' )) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste(">", round(runif(1, min = 70, max = 75))), LBSTRESC
#' )) %>%
#' ungroup()
#'
#' # original ARM value = dose value
#' arm_mapping <- list(
#' "A: Drug X" = "150mg QD",
#' "B: Placebo" = "Placebo",
#' "C: Combination" = "Combination"
#' )
#' 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"
#'
#' set.seed(1)
#' ADSL <- goshawk::rADSL
#' ADLB <- goshawk::rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(
#' AVISITCD = dplyr::case_when(
#' AVISIT == "SCREENING" ~ "SCR",
#' AVISIT == "BASELINE" ~ "BL",
#' grepl("WEEK", AVISIT) ~ paste("W", stringr::str_extract(AVISIT, "(?<=(WEEK ))[0-9]+")),
#' TRUE ~ as.character(NA)
#' ),
#' AVISITCDN = dplyr::case_when(
#' AVISITCD == "SCR" ~ -2,
#' AVISITCD == "BL" ~ 0,
#' grepl("W", AVISITCD) ~ as.numeric(gsub("[^0-9]*", "", AVISITCD)),
#' TRUE ~ as.numeric(NA)
#' ),
#' AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
#' TRTORD = dplyr::case_when(
#' ARMCD == "ARM C" ~ 1,
#' ARMCD == "ARM B" ~ 2,
#' ARMCD == "ARM A" ~ 3
#' ),
#' 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 = factor(ACTARM) %>% reorder(TRTORD),
#' ANRLO = 50,
#' ANRHI = 75
#' ) %>%
#' dplyr::rowwise() %>%
#' dplyr::group_by(PARAMCD) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste("<", round(runif(1, min = 25, max = 30))), LBSTRESC
#' )) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste(">", round(runif(1, min = 70, max = 75))), LBSTRESC
#' )) %>%
#' ungroup()
#' # add LLOQ and ULOQ variables
#' ALB_LOQS <- goshawk:::h_identify_loq_values(ADLB)
#' ADLB <- dplyr::left_join(ADLB, ALB_LOQS, by = "PARAM")
#' })
#'
#' 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"
#' datanames <- c("ADSL", "ADLB")
#' datanames(data) <- datanames
#'
#' # add LLOQ and ULOQ variables
#' ALB_LOQS <- goshawk:::h_identify_loq_values(ADLB)
#' ADLB <- dplyr::left_join(ADLB, ALB_LOQS, by = "PARAM")
#' join_keys(data) <- default_cdisc_join_keys[datanames]
#'
#' app <- teal::init(
#' data = teal.data::cdisc_data(
#' adsl <- teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- goshawk::rADSL"),
#' teal.data::cdisc_dataset(
#' "ADLB",
#' ADLB,
#' code = "
#' set.seed(1)
#' ADLB <- goshawk::rADLB
#' var_labels <- lapply(ADLB, function(x) attributes(x)$label)
#' ADLB <- ADLB %>%
#' dplyr::mutate(AVISITCD = dplyr::case_when(
#' AVISIT == 'SCREENING' ~ 'SCR',
#' AVISIT == 'BASELINE' ~ 'BL',
#' grepl('WEEK', AVISIT) ~ paste('W', stringr::str_extract(AVISIT, '(?<=(WEEK ))[0-9]+')),
#' TRUE ~ as.character(NA)),
#' AVISITCDN = dplyr::case_when(
#' AVISITCD == 'SCR' ~ -2,
#' AVISITCD == 'BL' ~ 0,
#' grepl('W', AVISITCD) ~ as.numeric(gsub('[^0-9]*', '', AVISITCD)),
#' TRUE ~ as.numeric(NA)),
#' AVISITCD = factor(AVISITCD) %>% reorder(AVISITCDN),
#' TRTORD = dplyr::case_when(
#' ARMCD == 'ARM C' ~ 1,
#' ARMCD == 'ARM B' ~ 2,
#' ARMCD == 'ARM A' ~ 3),
#' 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 = factor(ACTARM) %>% reorder(TRTORD),
#' ANRLO = 50,
#' ANRHI = 75) %>%
#' dplyr::rowwise() %>%
#' dplyr::group_by(PARAMCD) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste('<', round(runif(1, min = 25, max = 30))), LBSTRESC)) %>%
#' dplyr::mutate(LBSTRESC = ifelse(
#' USUBJID %in% sample(USUBJID, 1, replace = TRUE),
#' paste( '>', round(runif(1, min = 70, max = 75))), LBSTRESC)) %>%
#' ungroup()
#' 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 <- goshawk:::h_identify_loq_values(ADLB)
#' ADLB <- left_join(ADLB, ALB_LOQS, by = 'PARAM')",
#' vars = list(ADSL = adsl, arm_mapping = arm_mapping)
#' ),
#' check = FALSE # to shorten the example check = FALSE, in real scenarios use check = TRUE
#' ),
#' data = data,
#' modules = teal::modules(
#' teal.goshawk::tm_g_gh_boxplot(
#' label = "Box Plot",
Expand Down
Loading

0 comments on commit bd74b80

Please sign in to comment.