Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix teal.goshawk boxplot error #197

Closed
nikolas-burkoff opened this issue Oct 11, 2022 · 2 comments · Fixed by insightsengineering/goshawk#176
Closed

Fix teal.goshawk boxplot error #197

nikolas-burkoff opened this issue Oct 11, 2022 · 2 comments · Fixed by insightsengineering/goshawk#176
Assignees
Labels
bug Something isn't working core

Comments

@nikolas-burkoff
Copy link
Contributor

nikolas-burkoff commented Oct 11, 2022

Running examples in ‘teal.goshawk-Ex.R’ failed
The error most likely occurred in:

> ### Name: tm_g_gh_boxplot
> ### Title: Box Plot
> ### Aliases: tm_g_gh_boxplot
> 
> ### ** Examples
> 
> 
> # Example using ADaM structure analysis dataset.
> 
> library(dplyr)
> library(scda)

> library(nestcolor)
> 
> # original ARM value = dose value
> arm_mapping <- list(
+   "A: Drug X" = "150mg QD",
+   "B: Placebo" = "Placebo",
+   "C: Combination" = "Combination"
+ )
> 
> set.seed(1)
> cached_data <- synthetic_cdisc_data("latest")
> ADSL <- cached_data$adsl
> ADLB <- cached_data$adlb
> 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)
Error in `select()`:
! :1:5: unexpected symbol
1: Use of
        ^
Backtrace:
     ▆
  1. ├─goshawk:::h_identify_loq_values(ADLB)
  2. │ └─... %>% select(-.data$LBSTRESC)
  3. ├─dplyr::select(., -.data$LBSTRESC)
  4. ├─dplyr::ungroup(.)
  5. ├─dplyr::slice(., 1)
  6. ├─dplyr::group_by(., .data$PARAM)
  7. ├─dplyr::mutate(...)
  8. ├─dplyr::filter(., grepl("<", .data$LBSTRESC, fixed = FALSE))
  9. ├─dplyr::select(., .data$PARAM, .data$LBSTRESC)
 10. ├─dplyr:::select.data.frame(., .data$PARAM, .data$LBSTRESC)
 11. │ ├─dplyr:::tidyselect_fix_call(...)
 12. │ │ └─base::withCallingHandlers(...)
 13. │ └─tidyselect::eval_select(expr(c(...)), .data)
 14. │   └─tidyselect:::eval_select_impl(...)
 15. │     ├─tidyselect:::with_subscript_errors(...)
 16. │     │ └─rlang::try_fetch(...)
 17. │     │   └─base::withCallingHandlers(...)
 18. │     └─tidyselect:::vars_select_eval(...)
 19. │       └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
 20. │         └─tidyselect:::eval_c(expr, data_mask, context_mask)
 21. │           └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
 22. │             └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
 23. │               └─tidyselect:::expr_kind(expr, context_mask, error_call)
 24. │                 └─tidyselect:::call_kind(expr, context_mask, error_call)
 25. │                   └─lifecycle::deprecate_soft(...)
 26. │                     └─lifecycle::signal_stage("deprecated", what)
 27. │                       └─lifecycle:::spec(what, env = env)
 28. │                         └─lifecycle:::spec_what(spec, "spec", signaller)
 29. │                           └─rlang::parse_expr(what)
 30. │                             └─rlang::parse_exprs(x)
 31. │                               └─rlang:::chr_parse_exprs(x)
 32. │                                 └─rlang:::map(x, function(elt) as.list(parse(text = elt)))
 33. │                                   └─base::lapply(.x, .f, ...)
 34. │                                     └─rlang (local) FUN(X[[i]], ...)
 35. │                                       ├─base::as.list(parse(text = elt))
 36. │                                       └─base::parse(text = elt)
 37. └─base::.handleSimpleError(...)
 38.   └─dplyr (local) h(simpleError(msg, call))
 39.     └─rlang::cnd_signal(cnd)
@nikolas-burkoff
Copy link
Contributor Author

Not reproducible locally trying on source system

@nikolas-burkoff
Copy link
Contributor Author

Locally:
image
image

Source system:
image
image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant