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

Error in get(time) : invalid first argument #151

Closed
jlhanson5 opened this issue Apr 2, 2024 · 2 comments
Closed

Error in get(time) : invalid first argument #151

jlhanson5 opened this issue Apr 2, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jlhanson5
Copy link

Hello Colleagues,

I'm trying to test drive latrend, but ran into issues. I can run the demo, but with real data, I get the following output/error...

> method <- lcMethodKML("BrainAgeGap", id = "PSC2", time = "time", nClusters = 3)
> model <- latrend(method, IMAGEN_long)
             --------------------------------------------------------------
             - Longitudinal clustering using: longitudinal k-means (KML)
             --------------------------------------------------------------
             Method arguments:
              time:           "time"
              id:             "PSC2"
              nClusters:      3
              nbRedrawing:    20
              maxIt:          200
              imputationMethod:"copyMean"
              distanceName:   "euclidean"
              power:          2
              distance:       function() {}
              centerMethod:   meanNA
              startingCond:   "nearlyAll"
              nbCriterion:    1000
              scale:          TRUE
              response:       "BrainAgeGap"
             --------------------------------------------------------------
             Checking and transforming the training data format.
Error in get(time) : invalid first argument

here's my session info.

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.3.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
 [1] lubridate_1.9.3 forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4     purrr_1.0.2    
 [6] readr_2.1.5     tidyr_1.3.1     tibble_3.2.1    tidyverse_2.0.0 ggplot2_3.4.4  
[11] latrend_1.5.1  

loaded via a namespace (and not attached):
 [1] gtable_0.3.4             xfun_0.42                htmlwidgets_1.6.4       
 [4] remotes_2.4.2.1          processx_3.8.3           callr_3.7.3             
 [7] tzdb_0.4.0               ps_1.7.6                 vctrs_0.6.5             
[10] tools_4.3.2              Rdpack_2.6               generics_0.1.3          
[13] curl_5.2.0               rgl_1.3.1                fansi_1.0.6             
[16] cluster_2.1.4            pkgconfig_2.0.3          R.oo_1.26.0             
[19] data.table_1.15.0        longitudinalData_2.4.5.1 desc_1.4.3              
[22] assertthat_0.2.1         lifecycle_1.0.4          compiler_4.3.2          
[25] farver_2.1.1             munsell_0.5.0            codetools_0.2-19        
[28] misc3d_0.9-1             htmltools_0.5.7          class_7.3-22            
[31] pillar_1.9.0             R.utils_2.12.3           iterators_1.0.14        
[34] foreach_1.5.2            tidyselect_1.2.0         digest_0.6.34           
[37] stringi_1.8.3            labeling_0.4.3           fastmap_1.1.1           
[40] grid_4.3.2               colorspace_2.1-0         cli_3.6.2               
[43] magrittr_2.0.3           base64enc_0.1-3          pkgbuild_1.4.3          
[46] utf8_1.2.4               withr_3.0.0              scales_1.3.0            
[49] timechange_0.3.0         rmarkdown_2.25           matrixStats_1.2.0       
[52] clv_0.3-2.4              R.methodsS3_1.8.2        hms_1.1.3               
[55] kml_2.4.6.1              evaluate_0.23            knitr_1.45              
[58] rbibutils_2.2.16         tcltk_4.3.2              rlang_1.1.3             
[61] glue_1.7.0               rstudioapi_0.15.0        jsonlite_1.8.8          
[64] R6_2.5.1 

I don't really have more info about why the error is happening. I changed my data from a tbl_df to a data.frame, but that didn't solve the issue. And here's what my data.frame looks like:

> head(IMAGEN_long)
    PSC2 BrainAgeGap time
1 112288    0.814929    1
2 112288    1.083334    2
3 112288    1.249620    3
4 215284    2.034363    1
5 215284   -0.831310    2
6 215284    0.430477    3

Any suggestions about how to troubleshoot?

Many thanks,
Jamie.

@niekdt niekdt self-assigned this Apr 3, 2024
@niekdt niekdt added the bug Something isn't working label Apr 3, 2024
@niekdt niekdt added this to the 1.6.1 milestone Apr 3, 2024
@niekdt
Copy link
Collaborator

niekdt commented Apr 3, 2024

Hi Jamie, thanks for reporting this issue. This turned out to be a bug, caused by older code not handling dynamic data column evaluation in a robust way. Using an id or time variable with the name of a function would resolve to that function instead (stats::time in your case).

It should be fixed now in the latest commit. To install, use:

remotes::install_github('philips-software/latrend')

@jlhanson5
Copy link
Author

Perfect, that looks to have worked! Thanks for the quick change here!
I really appreciate it!

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

No branches or pull requests

2 participants