gcc-8: command not found (while installing randomForest) - r

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)

You should install the gcc8 tool:
sudo port install gcc8
Related Links
MacPorts - GCC8
YouTube - Install GCC 8 with Homebrew on macOS

Related

Unable to install a package called 'hemp' in R

I am new to learning R and i get the following error while installing the package called 'hemp'. Its a package which is used in psychometric analysis. Can anyone tell me what causes this errror?
Downloading GitHub repo cddesja/hemp#master
Installing 1 packages: nloptr
Installing package into ‘C:/Users/UJJWAL/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
There is a binary version available but the
source version is later:
binary source needs_compilation
nloptr 1.2.2.1 1.2.2.2 TRUE
installing the source package ‘nloptr’
trying URL 'https://cran.rstudio.com/src/contrib/nloptr_1.2.2.2.tar.gz'
Content type 'application/x-gzip' length 2450931 bytes (2.3 MB)
downloaded 2.3 MB
* installing *source* package 'nloptr' ...
** package 'nloptr' successfully unpacked and MD5 sums checked
** using staged installation
**********************************************
WARNING: this package has a configure script
It probably needs manual configuration
**********************************************
** libs
*** arch - i386
/mingw32/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-4.0.2/include" -DNDEBUG -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c dummy.cpp -o dummy.o
/mingw32/bin/gcc -I"C:/PROGRA~1/R/R-4.0.2/include" -DNDEBUG -I"/i386/include" -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c init_nloptr.c -o init_nloptr.o
init_nloptr.c:35:10: fatal error: nlopt.h: No such file or directory
#include "nlopt.h"
^~~~~~~~~
compilation terminated.
make: *** [C:/PROGRA~1/R/R-4.0.2/etc/i386/Makeconf:222: init_nloptr.o] Error 1
ERROR: compilation failed for package 'nloptr'
* removing 'C:/Users/UJJWAL/Documents/R/win-library/4.0/nloptr'
Error: Failed to install 'hemp' from GitHub:
(converted from warning) installation of package ‘nloptr’ had non-zero exit status
Seems that it wouldbe a little harder to install nloptr on Windows. It require nlopt to be installed first. See this for more info: https://www.r-project.org/nosvn/pandoc/nloptr.html

Package installation not working in R

Nevermind, fixed it. Will write up comment explaining fix tn.
I am trying to install the geometric morphometrics package in R, but whenever I try to install it, I get the following error message:
> install.packages("geomorph")
There is a binary version available but the source version is later: binary source needs_compilation geomorph 3.0.5 3.0.6 FALSE
installing the source package ‘geomorph’
trying URL 'https://cran.rstudio.com/src/contrib/geomorph_3.0.6.tar.gz'
Content type 'application/x-gzip' length 545863 bytes (533 KB)
==================================================
downloaded 533 KB
Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
unknown timezone 'default/America/Toronto'
* installing *source* package ‘geomorph’ ...
** package ‘geomorph’ successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘mvtnorm’
ERROR: lazy loading failed for package ‘geomorph’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/geomorph’
Warning in install.packages :
installation of package ‘geomorph’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/4p/m9yg9rg94v13j49zxnp9kzzh0000gn/T/RtmpCBCHAn/downloaded_packages’
I'm using RStudio but I tried it in just R, I've updated to the latest MacOS HighSierra, I have tried restarting the applications, I've installed and restarted XQuartz, and so far nothing has worked.
I'm running R on an early 2015 MacBook Air, I'm fresh out of ideas. Any suggestions are welcome.
EDIT:
Trying to install mvtnorm also failed, producing the following:
> install.packages("mvtnorm")
There is a binary version available but the source version is later:
binary source needs_compilation
mvtnorm 1.0-6 1.0-7 TRUE
Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘mvtnorm’
trying URL 'https://cran.rstudio.com/src/contrib/mvtnorm_1.0-7.tar.gz'
Content type 'application/x-gzip' length 159381 bytes (155 KB)
==================================================
downloaded 155 KB
* installing *source* package ‘mvtnorm’ ...
** package ‘mvtnorm’ successfully unpacked and MD5 sums checked
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG - I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC - Wall -mtune=core2 -g -O2 -c C_FORTRAN_interface.c -o C_FORTRAN_interface.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG - I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC - Wall -mtune=core2 -g -O2 -c miwa.c -o miwa.o
gfortran-4.8 -fPIC -g -O2 -c mvt.f -o mvt.o
make: gfortran-4.8: No such file or directory
make: *** [mvt.o] Error 1
ERROR: compilation failed for package ‘mvtnorm’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/mvtnorm’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/mvtnorm’
Warning in install.packages :
installation of package ‘mvtnorm’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/4p/m9yg9rg94v13j49zxnp9kzzh0000gn/T/RtmpCBCHAn/downloaded_packages’

Unable to install mclust package in rstudio

I am having an issue when installing the "mclust" package on rstudio.
Here is the warning message:
>install.packages("mclust")
trying URL 'https://cran.rstudio.com/src/contrib/mclust_5.4.tar.gz'
Content type 'application/x-gzip' length 2535477 bytes (2.4 MB)
==================================================
downloaded 2.4 MB
* installing *source* package ‘mclust’ ...
** package ‘mclust’ successfully unpacked and MD5 sums checked
** libs
/home/usr/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -
I/home/usr/anaconda3/lib/R/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2
-I/home/usr/anaconda3/include -fpic -march=nocona -mtune=haswell -
ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -
I/home/usr/anaconda3/include -c init.c -o init.o
make: /home/usr/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc: Command
not found
/home/usr/anaconda3/lib/R/etc/Makeconf:160: recipe for target 'init.o'
failed
make: *** [init.o] Error 127
ERROR: compilation failed for package ‘mclust’
* removing ‘/home/usr/anaconda3/lib/R/library/mclust’
Warning in install.packages :
installation of package ‘mclust’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpGCCIZS/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
In addition, I also tried to access the directory /home.usr/anaconda3/x86_64-conda_cos6-linux-gnu-cc ,which apparently doesn't exist.

gcc can't compile R packages under Linux Mint: can't find stdlib.h

I'm trying to install the R package gtools from the Linux Mint command line. After choosing the closest CRAN mirror, I'm getting the error message that no such file or directory was found and that installation of the package had a non-zero exit status. More specifically:
> install.packages('gtools')
Installing package into ‘/home/lizi/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cloud.r-
project.org/src/contrib/gtools_3.5.0.tar.gz'
Content type 'application/x-gzip' length 64855 bytes (63 KB)
==================================================
downloaded 63 KB
* installing *source* package ‘gtools’ ...
** package ‘gtools’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c roman2int.c -o roman2int.o
In file included from roman2int.c:1:0:
/usr/share/R/include/R.h:55:80: fatal error: stdlib.h: No such file or
directory
compilation terminated.
/usr/lib/R/etc/Makeconf:159: recipe for target 'roman2int.o' failed
make: *** [roman2int.o] Error 1
ERROR: compilation failed for package ‘gtools’
* removing ‘/home/lizi/R/x86_64-pc-linux-gnu-library/3.4/gtools’
The downloaded source packages are in
‘/tmp/Rtmp0z5PS6/downloaded_packages’
Warning message:
In install.packages("gtools") :
installation of package ‘gtools’ had non-zero exit status
The package has no dependencies, and I was under the impression that install.packages was straightforward. What am I doing wrong?

Cannot build R package "png" Fedora 20

I am trying to build the R package png, the repo says that libpng needs to be available.
I run a Linux Fedora 20 distro
Looks like I have it...
[root#localhost bin]# yum install libpng
Loaded plugins: langpacks, refresh-packagekit
Package 2:libpng-1.6.3-3.fc20.x86_64 already installed and latest version
Nothing to do
But when I try to install it:
> install.packages("png")
Installing package into ‘/home/statquant/R/x86_64-redhat-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/png_0.1-7.tar.gz'
Content type 'application/x-gzip' length 24990 bytes (24 Kb)
opened URL
==================================================
downloaded 24 Kb
* installing *source* package ‘png’ ...
** package ‘png’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include `libpng-config --cflags` -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c read.c -o read.o
/bin/sh: libpng-config: command not found
read.c:3:17: fatal error: png.h: No such file or directory
#include <png.h>
^
compilation terminated.
make: *** [read.o] Error 1
ERROR: compilation failed for package ‘png’
* removing ‘/home/statquant/R/x86_64-redhat-linux-gnu-library/3.0/png’
The downloaded source packages are in
‘/tmp/RtmpG5MjG9/downloaded_packages’
Warning message:
In install.packages("png") :
installation of package ‘png’ had non-zero exit status
For some R packages you need the corresponding development library to successfully install the R package. In your case this should do what you need
# Do the following in your terminal (not in an R session)
yum install libpng-devel
afterwards you should be able to install the R package
# Do the following in the R console (during an R session)
install.packages("png")
I had the same problem on Ubuntu (16.04) and solved it using
sudo apt-get install libpng-dev

Resources