matthias-da / robCompositions

Robust Methods for Compositional Data
11 stars 8 forks source link

impCoda with method=classical error: 'list' object cannot be coerced to type 'double' error #13

Closed DrewGoodfellow closed 3 years ago

DrewGoodfellow commented 3 years ago

Hello,

Thank you for developing such a useful R package for Compositional Data Analysis.I've discovered that if I run impCoda with method='classical', I get the following error: "Error in is.data.frame(x) : 'list' object cannot be coerced to type 'double' ".

Here is my SessionInfo and some sample code that generates the error. I'm using the latest version of robCompositions from CRAN.


sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 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/liblapack.so.3

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8   
 [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] robCompositions_2.3.0 data.table_1.14.0     pls_2.7-3             ggplot2_3.3.3        

loaded via a namespace (and not attached):
 [1] tidyr_1.1.3         splines_4.0.5       carData_3.0-4       rainbow_3.6         hdrcde_3.4          assertthat_0.2.1   
 [7] sp_1.4-5            stats4_4.0.5        cellranger_1.1.0    robustbase_0.93-7   pillar_1.6.0        VIM_6.1.0          
[13] lattice_0.20-44     glue_1.4.2          RColorBrewer_1.1-2  colorspace_2.0-1    Matrix_1.3-3        plyr_1.8.6         
[19] pcaPP_1.9-74        pkgconfig_2.0.3     haven_2.4.1         fda_5.1.9           purrr_0.3.4         mvtnorm_1.1-1      
[25] scales_1.1.1        ranger_0.12.1       openxlsx_4.2.3      rio_0.5.26          tibble_3.1.1        proxy_0.4-25       
[31] generics_0.1.0      car_3.0-10          ellipsis_0.3.2      withr_2.4.2         nnet_7.3-15         cli_2.5.0          
[37] survival_3.2-11     magrittr_2.0.1      crayon_1.4.1        readxl_1.3.1        mclust_5.4.7        fds_1.8            
[43] ks_1.12.0           GGally_2.1.1        laeken_0.5.1        fansi_0.4.2         MASS_7.3-53.1       truncnorm_1.0-8    
[49] forcats_0.5.1       foreign_0.8-81      class_7.3-19        tools_4.0.5         hms_1.0.0           lifecycle_1.0.0    
[55] kernlab_0.9-29      munsell_0.5.0       cluster_2.1.2       zip_2.1.1           fpc_2.2-9           compiler_4.0.5     
[61] e1071_1.7-6         vcd_1.4-8           rlang_0.4.11        grid_4.0.5          RCurl_1.98-1.3      cvTools_0.3.2      
[67] bitops_1.0-7        boot_1.3-27         gtable_0.3.0        abind_1.4-5         flexmix_2.3-17      DBI_1.1.1          
[73] reshape_0.8.8       curl_4.3.1          rrcov_1.5-5         R6_2.5.0            zoo_1.8-9           prabclus_2.3-2     
[79] dplyr_1.0.6         sROC_0.1-2          utf8_1.2.1          KernSmooth_2.23-18  modeltools_0.2-23   stringi_1.5.3      
[85] NADA_1.6-1.1        parallel_4.0.5      Rcpp_1.0.6          zCompositions_1.3.4 vctrs_0.3.8         diptest_0.76-0     
[91] DEoptimR_1.0-8      tidyselect_1.1.1    lmtest_0.9-38 

library(robCompositions)

data(expenditures)
x <- expenditures
x[1,3]
x[1,3] <- NA

X1 <-  impCoda(x, method = 'classical')

# Error in is.data.frame(x) : 
#   'list' object cannot be coerced to type 'double' 
matthias-da commented 3 years ago

Sorry, method impPCA is deprecated (which was internally called when selecting method classical. Is now explicitly mentioned (in the github version of the package). Thanks for reporting this.