error while installing vegan in r - r

When I tried to install vegan using install.packages("vegan") and using RStudio I am getting the following error message
* installing *source* package ‘vegan’ ...
** package ‘vegan’ successfully unpacked and MD5 sums checked
** libs
gfortran -fpic -g -O2 -fstack-protector-strong -c cepin.f -o cepin.o
/bin/bash: gfortran: command not found
/usr/lib/R/etc/Makeconf:157: recipe for target 'cepin.o' failed
make: *** [cepin.o] Error 127
ERROR: compilation failed for package ‘vegan’
* removing ‘/home/stephy/R/x86_64-pc-linux-gnu-library/3.2/vegan’
Warning in install.packages :
installation of package ‘vegan’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpoFztoS/downloaded_packages’

You need to install GFortran and make sure that it is in your PATH.
You can download a binary of it for your OS from here:
https://gcc.gnu.org/wiki/GFortranBinaries
Since you're on Linux after downloading it you can install it like this:
tar -xzvf gfortran-4.5-linux-i686.tar.gz -C /
Then add it to your PATH then try installing vegan again.

Related

R can't find icc to compile packages

I've compiled R-mkl package in Arch Linux using the Intel OneAPI compilers. But I cannot install packages from inside R, since it cannot find icc. The path in order to bash find the executables is defined in /etc/bash.bashrc:
export PATH="$PATH:/opt/intel/oneapi/compiler/latest/linux/bin/intel64/"
When I try to compile a package, it says it cannot find icc:
> install.packages("lazyeval")
Installing package into ‘/home/juliano/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
tentando a URL 'https://cran.rstudio.com/src/contrib/lazyeval_0.2.2.tar.gz'
Content type 'application/x-gzip' length 83482 bytes (81 KB)
==================================================
downloaded 81 KB
* installing *source* package ‘lazyeval’ ...
** package ‘lazyeval’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
icc -std=gnu11 -I"/usr/include/R/" -DNDEBUG -I/usr/local/include -fpic -O3 -fPIC -m64 -march=native -fp-model precise -fp-model source -I/opt/intel/mkl/include -c expr.c -o expr.o
/bin/sh: linha 1: icc: command not found
make: *** [/usr/lib64/R/etc/Makeconf:169: expr.o] Erro 127
ERROR: compilation failed for package ‘lazyeval’
* removing ‘/home/juliano/R/x86_64-pc-linux-gnu-library/4.2/lazyeval’
Warning in install.packages :
installation of package ‘lazyeval’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpPvcR2C/downloaded_packages’
How I do instruct R to read /etc/bash.bashrc or define the path to the compilers manually?
I have also tried to define the path in a file in /etc/profile.d, without success.
You can try sourcing setvars.sh script to initiate the OneAPI environment.
source /opt/intel/oneapi/setvars.sh
As you said, it will work if you create a symlink to the /bin.
Refer to the below link to get more details on usage of R with Intel OneAPI
https://www.intel.com/content/www/us/en/developer/articles/technical/using-onemkl-with-r.html

Why some R packages can't be installed

I've been using R for a while and everything was normal when installing packages. Recently, I upgraded R on my Ubuntu 16.04 from 3.4.4 to 4.0.2 and then I tried to install the package imputeTS as
> install.packages("imputeTS")
Installing package into ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependencies ‘png’, ‘gridtext’, ‘ggtext’
trying URL 'https://cloud.r-project.org/src/contrib/png_0.1-7.tar.gz'
Content type 'application/x-gzip' length 24990 bytes (24 KB)
==================================================
downloaded 24 KB
trying URL 'https://cloud.r-project.org/src/contrib/gridtext_0.1.1.tar.gz'
Content type 'application/x-gzip' length 441462 bytes (431 KB)
==================================================
downloaded 431 KB
trying URL 'https://cloud.r-project.org/src/contrib/ggtext_0.1.0.tar.gz'
Content type 'application/x-gzip' length 1849875 bytes (1.8 MB)
==================================================
downloaded 1.8 MB
trying URL 'https://cloud.r-project.org/src/contrib/imputeTS_3.1.tar.gz'
Content type 'application/x-gzip' length 3015320 bytes (2.9 MB)
==================================================
downloaded 2.9 MB
* installing *source* package ‘png’ ...
** package ‘png’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG `libpng-config --cflags` -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c read.c -o read.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG `libpng-config --cflags` -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c write.c -o write.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o png.so read.o write.o -L/home/.../anaconda/lib -lpng16 -lm -lz -lm -L/usr/lib/R/lib -lR
installing to /home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘png’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs/png.so':
libpng16.so.16: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/png’
ERROR: dependency ‘png’ is not available for package ‘gridtext’
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/gridtext’
ERROR: dependency ‘gridtext’ is not available for package ‘ggtext’
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/ggtext’
ERROR: dependency ‘ggtext’ is not available for package ‘imputeTS’
* removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/imputeTS’
The downloaded source packages are in
‘/tmp/RtmpZubgYt/downloaded_packages’
Warning messages:
1: In install.packages("imputeTS") :
installation of package ‘png’ had non-zero exit status
2: In install.packages("imputeTS") :
installation of package ‘gridtext’ had non-zero exit status
3: In install.packages("imputeTS") :
installation of package ‘ggtext’ had non-zero exit status
4: In install.packages("imputeTS") :
installation of package ‘imputeTS’ had non-zero exit status
Then
> library(imputeTS)
Error in library(imputeTS) : there is no package called ‘imputeTS’
I tried to install the same package as install.packages("imputeTS", dependencies = TRUE) but this gave me the same result installation of package ‘imputeTS’ had non-zero exit status
Following, I tried to install the packages Hmisc and mice. The same result was for the first package where as mice was installed successfully!
Two more comments, the first is this statement (as ‘lib’ is unspecified) started to appear just after upgrading R. The second, I am not sure if related, is that there is no space on my linux!
So how could I install the needed packages successfuly?
Just a wrap up that people can find the correct answer given in the comments better and understand the error messages
This is no problem related specifically to the imputeTS package.
This can be seen in this part of the error message
Error: package or namespace load failed for ‘png’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs/png.so':
libpng16.so.16: cannot open shared object file: No such file or directory
The error actually occurs while trying to install the png package.
How is this related to the imputeTS package?
You can see this here:
ERROR: loading failed
removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/png’
ERROR: dependency ‘png’ is not available for package ‘gridtext’
removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/gridtext’
ERROR: dependency ‘gridtext’ is not available for package ‘ggtext’
removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/ggtext’
ERROR: dependency ‘ggtext’ is not available for package ‘imputeTS’
removing ‘/home/.../R/x86_64-pc-linux-gnu-library/4.0/imputeTS’
R packages build on each other and import functions of other packages. In this case imputeTS imports ggtext, which imports gridtext, which imports png.
So quite a sequence of dependencies and if installation of png fails, this affects all the other packages.
Luckily this part of the error message also gives a hint, what could be wrong:
unable to load shared object '/home/.../R/x86_64-pc-linux-gnu-library/4.0/00LOCK-png/00new/png/libs/png.so':
libpng16.so.16: cannot open shared object file: No such file or directory
There is a library missing on which the png package itself depends on. Without this library the installation of png will fail and cause all these mentioned issues.
So just install the library like this:
sudo apt-get install libpng16-16

Trouble installing package rms for Rstudio

I have been having an issue installing package rms. I am trying to interpret ordinal models (using the package ordinal) and plot regressions using them. For rms, I don't even get an error, just that it updates other loaded packages, loads and attaches package 'lubridate' which had already been installed, and that 'date' is masked from the base package.
For reference I had originally tried to install hmisc, which I found out was a dependency for rms. This led to an issue installing dependency gfortran. When I attempt to install gfortran, I get
package ‘gfortran’ is not available (for R version 3.5.1)
But then, when I try to install Hmisc, I get
installing the source package ‘Hmisc’
trying URL 'https://cran.rstudio.com/src/contrib/Hmisc_4.4-0.tar.gz'
Content type 'application/x-gzip' length 744545 bytes (727 KB)
==================================================
downloaded 727 KB
* installing *source* package ‘Hmisc’ ...
** package ‘Hmisc’ successfully unpacked and MD5 sums checked
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c Hmisc.c -o Hmisc.o
gfortran -fPIC -g -O2 -c cidxcn.f -o cidxcn.o
make: gfortran: No such file or directory
make: *** [cidxcn.o] Error 1
ERROR: compilation failed for package ‘Hmisc’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Hmisc’
Warning in install.packages :
installation of package ‘Hmisc’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/5l/r40ht3p511j0mbty0ptcc7zm0000gn/T/RtmpFAI0pw/downloaded_packages’
For reference, I run this on a Mac OS Catalina (10.15.4).
Alternatively, if you have any other ways to graph regressions using ordinal models please let me know! Thank you very much.
I got a similar error even though I had installed gfortran by running brew install gfortran. But I needed to add this to my ~/.Rprofile:
Sys.setenv(PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin")

“installation of package tuneR had non-zero exit status” in R

OS: Ubuntu 18.04
R version: 3.4.3 and 3.4.4
I tried to install tuneR with install.packages("tuneR") in R 3.4.3 and R 3.4.4 but I get this error:
* installing *source* package ‘signal’ ...
package ‘signal’ successfully unpacked and MD5 sums checked
libs
gfortran -fpic -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -c dpchim.f -o dpchim.o
/bin/bash: gfortran: command not found
/usr/lib/R/etc/Makeconf:182: recipe for target 'dpchim.o' failed
make: *** [dpchim.o] Error 127
ERROR: compilation failed for package ‘signal’
* removing ‘/home/helias/R/x86_64-pc-linux-gnu-library/3.4/signal’
ERROR: dependency ‘signal’ is not available for package ‘tuneR’
* removing ‘/home/helias/R/x86_64-pc-linux-gnu-library/3.4/tuneR’
The downloaded source packages are in
‘/tmp/RtmpL1f4HR/downloaded_packages’
Warning messages:
1: In install.packages("tuneR") :
installation of package ‘signal’ had non-zero exit status
2: In install.packages("tuneR") :
installation of package ‘tuneR’ had non-zero exit status
(I also used RStudio)
I solved installing gfortran and after re-run install.packages("tuneR")
sudo apt install gfortran
You can try downloading the source and install from RStudio. tuneR is available at:
https://CRAN.R-project.org/package=tuneR
Download the .tar.gz file and install locally. You can install using through RStudio (Packages tab -> change install from: Package), or you can install through the terminal using
R CMD INSTALL -l /path tuneR.tar.gz
Another option is
> library(devtools)
> install_github("cran/tuneR")

R install `KFKSDS` on mac

I am trying to install tsoutliers library in R where only the source is available and it doesn't has a CRAN package available. Also, KFKSDS in one of the dependencies that have to be installed, again, it is source code version available only.
I used brew to have gsl installed but when I tried to install KFKSDS, it still errorred out. On the other side, I installed gsl, gsl-devel, KFKSDS and tsoutliers easily on the redhat server. Can anyone show me how can I installed it successfully on my Mac. I am using R 3.1.1 which is not cutting edge but should be good enough, I guess.
> install.packages("KFKSDS", type="source")
trying URL 'http://cran.rstudio.com/src/contrib/KFKSDS_1.5.tar.gz'
Content type 'application/x-gzip' length 30272 bytes (29 Kb)
opened URL
==================================================
downloaded 29 Kb
* installing *source* package ‘KFKSDS’ ...
** package ‘KFKSDS’ successfully unpacked and MD5 sums checked
** libs
g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -mtune=core2 -g -O2 -c KF-deriv.cpp -o KF-deriv.o
In file included from /usr/include/c++/4.2.1/bits/locale_facets.h:1539,
from /usr/include/c++/4.2.1/bits/basic_ios.h:44,
from /usr/include/c++/4.2.1/ios:50,
from /usr/include/c++/4.2.1/ostream:45,
from /usr/include/c++/4.2.1/iterator:70,
from /usr/include/c++/4.2.1/numeric:67,
from KFKSDS.h:12,
from KF-deriv.cpp:1:
/usr/include/c++/4.2.1/bits/codecvt.h:219:45: error: macro "length" passed 4 arguments, but takes just 1
In file included from /usr/include/c++/4.2.1/bits/locale_facets.h:1539,
from /usr/include/c++/4.2.1/bits/basic_ios.h:44,
from /usr/include/c++/4.2.1/ios:50,
from /usr/include/c++/4.2.1/ostream:45,
from /usr/include/c++/4.2.1/iterator:70,
from /usr/include/c++/4.2.1/numeric:67,
from KFKSDS.h:12,
from KF-deriv.cpp:1:
/usr/include/c++/4.2.1/bits/codecvt.h:218: error: expected ‘;’ before ���const’
/usr/include/c++/4.2.1/bits/codecvt.h:222: error: expected `;' before ‘int’
make: *** [KF-deriv.o] Error 1
ERROR: compilation failed for package ‘KFKSDS’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/KFKSDS’
Warning in install.packages :
installation of package ‘KFKSDS’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/d2/ffftfj193ng339zrc3jbdv75m9ssv9/T/RtmpgJshhe/downloaded_packages’

Resources