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: derive_vars_period fails when there is only one new var #2582

Closed
clarkliming opened this issue Nov 28, 2024 · 0 comments · Fixed by #2583
Closed

Bug: derive_vars_period fails when there is only one new var #2582

clarkliming opened this issue Nov 28, 2024 · 0 comments · Fixed by #2583
Labels
bug Something isn't working programming

Comments

@clarkliming
Copy link
Contributor

clarkliming commented Nov 28, 2024

What happened?

derive_vars_period fails when there are only one new_vars

Session Information

R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

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

time zone: Etc/UTC
tzcode source: system (glibc)

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

other attached packages:
[1] admiral_1.1.1.9030 tidyr_1.3.0        testthat_3.2.0    

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4 devtools_2.4.5    remotes_2.5.0     processx_3.8.2   
 [5] callr_3.7.3       vctrs_0.6.4       tools_4.3.3       ps_1.7.5         
 [9] generics_0.1.3    tibble_3.2.1      fansi_1.0.5       pkgconfig_2.0.3  
[13] desc_1.4.2        lifecycle_1.0.3   compiler_4.3.3    stringr_1.5.0    
[17] brio_1.1.3        httpuv_1.6.15     htmltools_0.5.8.1 usethis_2.2.2    
[21] later_1.3.2       pillar_1.9.0      crayon_1.5.2      urlchecker_1.0.1 
[25] ellipsis_0.3.2    cachem_1.1.0      sessioninfo_1.2.2 mime_0.12        
[29] tidyselect_1.2.0  digest_0.6.33     stringi_1.7.12    dplyr_1.1.3      
[33] purrr_1.0.2       rprojroot_2.0.3   fastmap_1.2.0     cli_3.6.3        
[37] magrittr_2.0.3    pkgbuild_1.4.2    utf8_1.2.3        withr_2.5.1      
[41] admiraldev_1.1.0  diffdf_1.0.4      prettyunits_1.2.0 waldo_0.5.3      
[45] promises_1.3.0    lubridate_1.9.3   timechange_0.2.0  hms_1.1.3        
[49] memoise_2.0.1     shiny_1.9.1       evaluate_0.22     miniUI_0.1.1.1   
[53] profvis_0.3.8     rlang_1.1.1       Rcpp_1.0.11       xtable_1.8-4     
[57] glue_1.8.0        pkgload_1.3.3     rstudioapi_0.15.0 R6_2.5.1         
[61] fs_1.6.3     

Reproducible Example

expected <- tibble::tribble(
    ~USUBJID, ~AP01SDT,
    "1",      "2021-01-04",
    "2",      "2021-02-02",
  ) %>%
    mutate(
      across(matches("AP\\d\\d[ES]DT"), ymd)
    ) %>%
    mutate(
      STUDYID = "xyz"
    )

  period_ref <- tibble::tribble(
    ~USUBJID, ~APERIOD, ~APERSDT,     ~APEREDT,     ~APERSDTM,             ~APEREDTM,
    "1",             1, "2021-01-04", "2021-02-06", "2021-01-04 10:01:02", "2021-02-06 14:03:04",
    "2",             1, "2021-02-02", "2021-03-02", "2021-02-02 04:11:34", "2021-03-02 16:55:59"
  ) %>%
    mutate(
      STUDYID = "xyz",
      APERIOD = as.integer(APERIOD),
      APERSDT = ymd(APERSDT),
      APEREDT = ymd(APEREDT),
      APERSDTM = ymd_hms(APERSDTM),
      APEREDTM = ymd_hms(APEREDTM)
    )

  adsl <- tibble::tibble(STUDYID = "xyz", USUBJID = c("1", "2"))

derive_vars_period(
      adsl,
      dataset_ref = period_ref,
      new_vars = exprs(APxxSDT = APERSDT)
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working programming
Development

Successfully merging a pull request may close this issue.

1 participant