Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R package 'randomForest' not installing

I have been trying to install the R package 'randomForest', to do this I ran the usual installation command

install.packages("randomForest", dependencies = T)

This gives me the following error, which I've been having trouble interpreting. It seems to me that something is missing from the folder for another R package, 'RccpEigen', and that is causing an error, but I'm not sure and I haven't been able to find how to fix that.

The full error message is this:

Installing package into ‘/home/scott/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/randomForest_4.6-14.tar.gz'
Content type 'application/x-gzip' length 80074 bytes (78 KB)
==================================================
downloaded 78 KB

* installing *source* package ‘randomForest’ ...
** package ‘randomForest’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG   -I"/home/scott/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include/"  -I"/home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/"  -I"/home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/unsupported"  -I"/home/scott/R/x86_64-pc-linux-gnu-library/3.6/BH/include" -I"/home/scott/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/include/src/"  -I"/home/scott/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/include/"  -I"/home/scott/R/x86_64-pc-linux-gnu-library/3.6/rstan/include" -DEIGEN_NO_DEBUG  -D_REENTRANT  -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-V28x5H/r-base-3.6.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c classTree.c -o classTree.o
In file included from /home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/Eigen/Core:88:0,
                 from /home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/Eigen/Dense:1,
                 from /home/scott/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from <command-line>:0:
/home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/Eigen/src/Core/util/Macros.h:613:1: error: unknown type name ‘namespace’
 namespace Eigen {
 ^~~~~~~~~
/home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/Eigen/src/Core/util/Macros.h:613:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 namespace Eigen {
                 ^
In file included from /home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/Eigen/Dense:1:0,
                 from /home/scott/R/x86_64-pc-linux-gnu-library/3.6/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from <command-line>:0:
/home/scott/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen/include/Eigen/Core:96:10: fatal error: complex: No such file or directory
 #include <complex>
          ^~~~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:168: recipe for target 'classTree.o' failed
make: *** [classTree.o] Error 1
ERROR: compilation failed for package ‘randomForest’
* removing ‘/home/scott/R/x86_64-pc-linux-gnu-library/3.6/randomForest’
Warning in install.packages :
  installation of package ‘randomForest’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpbKxumd/downloaded_packages’ 

Here is my session info:

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

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

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

other attached packages:
[1] RcppEigen_0.3.3.7.0 lme4_1.1-21         Matrix_1.2-18       ggplot2_3.3.0       Rmisc_1.5           plyr_1.8.6         
[7] lattice_0.20-38     brms_2.12.0         Rcpp_1.0.4         

loaded via a namespace (and not attached):
  [1] nlme_3.1-144         matrixStats_0.56.0   xts_0.12-0           threejs_0.3.3        rstan_2.19.3         tools_3.6.3         
  [7] backports_1.1.6      R6_2.4.1             DT_0.13              colorspace_1.4-1     withr_2.1.2          tidyselect_1.0.0    
 [13] gridExtra_2.3        prettyunits_1.1.1    processx_3.4.2       Brobdingnag_1.2-6    curl_4.3             compiler_3.6.3      
 [19] cli_2.0.2            shinyjs_1.1          labeling_0.3         colourpicker_1.0     checkmate_2.0.0      scales_1.1.0        
 [25] dygraphs_1.1.1.6     mvtnorm_1.1-0        readr_1.3.1          ggridges_0.5.2       callr_3.4.3          stringr_1.4.0       
 [31] digest_0.6.25        StanHeaders_2.19.2   foreign_0.8-75       minqa_1.2.4          rio_0.5.16           base64enc_0.1-3     
 [37] pkgconfig_2.0.3      htmltools_0.4.0      fastmap_1.0.1        readxl_1.3.1         htmlwidgets_1.5.1    rlang_0.4.5         
 [43] rstudioapi_0.11      shiny_1.4.0.2        farver_2.0.3         zoo_1.8-7            crosstalk_1.1.0.1    gtools_3.8.2        
 [49] zip_2.0.4            dplyr_0.8.5          car_3.0-7            inline_0.3.15        magrittr_1.5         loo_2.2.0           
 [55] bayesplot_1.7.1      munsell_0.5.0        fansi_0.4.1          abind_1.4-5          lifecycle_0.2.0      stringi_1.4.6       
 [61] carData_3.0-3        MASS_7.3-51.5        pkgbuild_1.0.6       grid_3.6.3           parallel_3.6.3       promises_1.1.0      
 [67] forcats_0.4.0        crayon_1.3.4         miniUI_0.1.1.1       haven_2.2.0          splines_3.6.3        hms_0.5.3           
 [73] ps_1.3.2             pillar_1.4.3         igraph_1.2.5         boot_1.3-24          markdown_1.1         shinystan_2.5.0     
 [79] codetools_0.2-16     reshape2_1.4.3       stats4_3.6.3         rstantools_2.0.0     glue_1.4.0           data.table_1.12.8   
 [85] vctrs_0.2.4          nloptr_1.2.1         httpuv_1.5.2         cellranger_1.1.0     gtable_0.3.0         purrr_0.3.3         
 [91] assertthat_0.2.1     openxlsx_4.1.4       mime_0.9             xtable_1.8-4         coda_0.19-3          later_1.0.0         
 [97] rsconnect_0.8.16     tibble_3.0.0         shinythemes_1.1.2    ellipsis_0.3.0       bridgesampling_1.0-0
> 

Any help would be greatly appreciated, as I'm in over my head here programming-wise.

like image 491
sjp Avatar asked Apr 26 '26 08:04

sjp


1 Answers

I suspect this is an RStudio issue.

Install randomForest in base R, then you should be able to load in RStudio using library.

like image 185
Tim Assal Avatar answered Apr 28 '26 21:04

Tim Assal