Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bug: Not able to rename variables with derive_vars_last_dose() #1206

Closed
thomas-neitmann opened this issue Jun 9, 2022 · 1 comment · Fixed by #1311
Closed

Bug: Not able to rename variables with derive_vars_last_dose() #1206

thomas-neitmann opened this issue Jun 9, 2022 · 1 comment · Fixed by #1311
Assignees
Labels
bug Something isn't working hotfix Issue to be released in the next patch release programming

Comments

@thomas-neitmann
Copy link
Contributor

What happened?

derive_vars_last_dose() returns an error when using the new_vars parameter to rename variables.

Session Information

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rice_2.0        lubridate_1.7.8 dplyr_1.0.0     admiral_0.7.0  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6     tidyr_1.0.2      crayon_1.3.4     assertthat_0.2.1 R6_2.4.1         lifecycle_0.2.0 
 [7] magrittr_1.5     httr_1.4.1       pillar_1.4.3     stringi_1.4.6    rlang_1.0.2      cli_3.3.0       
[13] rstudioapi_0.11  vctrs_0.4.1      generics_0.0.2   ellipsis_0.3.2   tools_3.6.3      stringr_1.4.0   
[19] glue_1.6.2       purrr_0.3.4      hms_0.5.3        compiler_3.6.3   pkgconfig_2.0.3  tidyselect_1.1.0
[25] tibble_3.0.1    

Reproducible Example

adae <- tibble::tribble(
  ~USUBJID, ~AESTDTC, ~AENDTC, ~ASTDT, ~AENDT, ~AEDECOD,
  "P01", "2022-01-10", "2022-01-12", ymd("2022-01-10"), ymd("2022-01-12"), "Nausea",
  "P02", "2022-01-31", "2022-01-31",ymd("2022-01-31"), ymd("2022-01-31"), "Vomitting",
  "P02", "2022-02-02", "2022-02-04", ymd("2022-02-02"), ymd("2022-02-04"), "Vomitting"
)

adex <- tibble::tribble(
  ~USUBJID, ~EXTRT, ~EXDOSFRQ, ~EXSTDTC, ~EXENDTC, ~ASTDT, ~AENDT,
  "P01", "Drug A", "QD", "2022-01-09", "2022-01-12", ymd("2022-01-09"), ymd("2022-01-12"),
  "P02", "Drug A", "QD", "2022-02-01", "2022-02-04", ymd("2022-02-01"), ymd("2022-02-04")
)

(adex_single <- create_single_dose_dataset(adex))

derive_vars_last_dose(
  adae,
  adex_single,
  by_vars = vars(USUBJID),
  dose_date = EXSTDT,
  analysis_date = AESTDTC,
  new_vars = vars(EXSTDT = ASTDT)
)
Error in `assert_data_frame()`:
! Required variable `EXSTDT` is missing
Run `rlang::last_error()` to see where the error occurred.
@thomas-neitmann thomas-neitmann added bug Something isn't working programming labels Jun 9, 2022
@thomas-neitmann thomas-neitmann self-assigned this Jun 14, 2022
@thomas-neitmann thomas-neitmann changed the title Bug: Not able to rename varaibles with derive_vars_last_dose() Bug: Not able to rename variables with derive_vars_last_dose() Jun 14, 2022
@bundfussr bundfussr added the hotfix Issue to be released in the next patch release label Jun 14, 2022
@thomas-neitmann
Copy link
Contributor Author

Upon further inspection the error is not related to the renaming itsef. That works as expected. However, if a renamed variable is specified in dose_date as per the example above then the assert_data_frame() call errors because that renames variable is not yet in the dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hotfix Issue to be released in the next patch release programming
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants