1

I'm trying to install "randomForest" on R 3.6.3 as below:

urlPackage <- "https://cran.r-project.org/src/contrib/Archive/randomForest/randomForest_4.6-14.tar.gz"
install.packages(urlPackage, repos=NULL, type="source")

(install.packages('randomForest') throws the error: package 'randomForest' is not available (for R version 3.6.3))

The lines above, however, give me the following error:

    trying URL 'https://cran.r-project.org/src/contrib/Archive/randomForest/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-8 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -mtune=native -g -O2 -Wall -pedantic -Wconversion -c classTree.c -o classTree.o
/bin/sh: gcc-8: command not found
make: *** [classTree.o] Error 127
ERROR: compilation failed for package ‘randomForest’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/randomForest’
Warning in install.packages :
  installation of package ‘/var/folders/66/3s4r17rx7ln0b1p8tyrmws780000gn/T//RtmpDOHynP/downloaded_packages/randomForest_4.6-14.tar.gz’ had non-zero exit status

Does anyone have any idea how to solve this? I'm on macOS Catalina (ver 10.15.7)

Phil
  • 7,287
  • 3
  • 36
  • 66
klein
  • 13
  • 3

1 Answers1

0

You should install the gcc8 tool:

sudo port install gcc8

Related Links

Sercan
  • 4,739
  • 3
  • 17
  • 36
  • 1
    Thanks! It turned out gcc8 isn't compatible with my macOS & I had gcc11 installed already. I edited ~/.R/Makevars/ as follows and it worked!: VER=-11 CC=gcc$(VER) CXX=g++$(VER) CXX11=g++$(VER) CXX14=g++$(VER) CXX17=g++$(VER) CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion FLIBS=-L/usr/local/Cellar/gcc/8.2.0/lib/gcc/11 – klein Jul 23 '22 at 00:44