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: slice_derivation() return non-meaningful dataset when input dataset is of 0 row #2645

Open
clarkliming opened this issue Jan 17, 2025 · 0 comments · May be fixed by #2646
Open

Bug: slice_derivation() return non-meaningful dataset when input dataset is of 0 row #2645

clarkliming opened this issue Jan 17, 2025 · 0 comments · May be fixed by #2646
Labels
bug Something isn't working programming

Comments

@clarkliming
Copy link
Contributor

What happened?

using empty (0-row) data set and call slice_derivation will give strange result

advs <- tibble::tribble(
    ~USUBJID, ~VSDTC,       ~VSTPT,             ~VSSEQ,
    "1",      "2020-04-16", NA_character_,      1,
    "1",      "2020-04-16", "BEFORE TREATMENT", 2
  )

  actual <- slice_derivation(
    advs[c(-1, -2), ],
    derivation = derive_vars_dtm,
    args = params(
      dtc = VSDTC,
      new_vars_prefix = "A"
    ),
    derivation_slice(
      filter = str_detect(VSTPT, "PRE|BEFORE"),
      args = params(time_imputation = "first")
    ),
    derivation_slice(
      filter = TRUE,
      args = params(time_imputation = "last")
    )
  )
> actual
# A tibble: 0 × 1
# ℹ 1 variable: data <???>

it breaks down the data structure and cause issues (when there are just no records in the dataset)

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.2.0.9002 testthat_3.2.0    

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4     devtools_2.4.5        remotes_2.5.0        
 [4] processx_3.8.2        callr_3.7.3           vctrs_0.6.4          
 [7] tools_4.3.3           ps_1.7.5              generics_0.1.3       
[10] 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       
[16] stringr_1.5.0         brio_1.1.3            httpuv_1.6.15        
[19] htmltools_0.5.8.1     usethis_2.2.2         later_1.4.1          
[22] pillar_1.9.0          crayon_1.5.2          urlchecker_1.0.1     
[25] tidyr_1.3.0           ellipsis_0.3.2        cachem_1.1.0         
[28] sessioninfo_1.2.2     mime_0.12             tidyselect_1.2.0     
[31] digest_0.6.33         stringi_1.7.12        rematch2_2.1.2       
[34] diffobj_0.3.5         dplyr_1.1.3           purrr_1.0.2          
[37] rprojroot_2.0.3       fastmap_1.2.0         cli_3.6.3            
[40] magrittr_2.0.3        pkgbuild_1.4.2        utf8_1.2.3           
[43] withr_2.5.1           admiraldev_1.2.0.9001 diffdf_1.0.4         
[46] prettyunits_1.2.0     waldo_0.5.3           promises_1.3.2       
[49] lubridate_1.9.3       timechange_0.2.0      hms_1.1.3            
[52] memoise_2.0.1         shiny_1.10.0          miniUI_0.1.1.1       
[55] profvis_0.3.8         rlang_1.1.1           Rcpp_1.0.11          
[58] xtable_1.8-4          glue_1.8.0            pkgload_1.3.3        
[61] rstudioapi_0.17.1     R6_2.5.1              fs_1.6.3 

Reproducible Example

advs <- tibble::tribble(
~USUBJID, ~VSDTC, ~VSTPT, ~VSSEQ,
"1", "2020-04-16", NA_character_, 1,
"1", "2020-04-16", "BEFORE TREATMENT", 2
)

actual <- slice_derivation(
advs[c(-1, -2), ],
derivation = derive_vars_dtm,
args = params(
dtc = VSDTC,
new_vars_prefix = "A"
),
derivation_slice(
filter = str_detect(VSTPT, "PRE|BEFORE"),
args = params(time_imputation = "first")
),
derivation_slice(
filter = TRUE,
args = params(time_imputation = "last")
)
)

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