R: upgrading Hmisc on Debian Lenny - r

When I bring up a basic image of Debian Lenny on EC2 (actually EMR on EC2) I get Lenny version 5.0.7 and I am able to upgrade R using the method outlined in a previous question. After upgrading R I have version 2.12.
I've been unable to then install the Hmisc package. I see that it has a Debian package so I've tried:
sudo apt-get update
sudo apt-get install r-cran-hmisc
Which seems to work, but when I go into R I get the following:
> require(Hmisc)
Loading required package: Hmisc
Failed with error: ‘package 'Hmisc' was built before R 2.10.0: please re-install it’
so I presume the Hmisc in the Debian repo is an old version. So I'll just upgrade. So I go into R and:
install.packages("Hmisc")
which fails with:
...
gcc -I/usr/share/R/include -fpic -std=gnu99 -O3 -pipe -g -c string_box.c -o string_box.o
gfortran -fpic -O3 -pipe -g -c wclosest.f -o wclosest.o
gcc -shared -o Hmisc.so Hmisc.o cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o mChoice.o nstr.o ranksort.o rcorr.o string_box.o wclosest.o -lgfortran -lm -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
collect2: ld returned 1 exit status
make: *** [Hmisc.so] Error 1
ERROR: compilation failed for package ‘Hmisc’
* removing ‘/home/hadoop/R/x86_64-pc-linux-gnu-library/2.12/Hmisc’
The downloaded packages are in
‘/tmp/Rtmp2Ej5Tn/downloaded_packages’
Warning message:
In install.packages("Hmisc") :
installation of package 'Hmisc' had non-zero exit status
>
It appears like ld is struggling with lgfortran. I checked and gfortran is installed. So I tried installing gfortran-4.1:
sudo apt-get install gfortran-4.1
That didn't change anything. Nor did installing 4.2.
Any tips on what to try next?

What happens when you install the r-base-dev package? Does it build then? It should.

I stumbled upon this previous question right after I posted here. It appears I need to manually link to the gfortran libraries:
sudo ln -s /usr/lib/libgfortran.so.3 /usr/lib/libgfortran.so
After updating the cluster package I am able to install.packages("Hmisc")

Related

Problem installing "nloptr" in R 4.2.2 on Ubuntu 22.04

My installation of "ggpubr" on Rstudio (based on R 4.2.2) in Ubuntu 22.04 failed because of issues in installing "nloptr". I installed NLOPT based on guides in https://nlopt.readthedocs.io/en/latest/NLopt_Installation/, but nloptr installation is still failing but with another kind of error.
Here are the last lines:
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o nloptr.so init_nloptr.o nloptr.o test-C-API.o test-runner.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/local/lib -lnlopt -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -llapack: No such file or directory
/usr/bin/ld: cannot find -lblas: No such file or directory
/usr/bin/ld: cannot find -lgfortran: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:10: nloptr.so] Error 1
ERROR: compilation failed for package ‘nloptr’
Any help is appreciated.
Best,
Amir
The comments by #jay.sf and myself give you the narrowest answer: you attempt to build from source, and compiling and linking requires the so-called -dev packages. So install r-base-dev.
Looking beyond this for a second though, you are on Ubuntu 22.04 and you have r-cran-nloptr inside the distribution too (albeit an older version). So sudo apt install r-cran-nloptr works as well.
And since this summer there is r2u which gives you (on Ubuntu 20.04 and Ubuntu 22.04) every CRAN package as an Ubuntu binary and is generally current. It is easy to set up and the command install.packages("ggpubr") would then reliably and quickly install the package and all its dependencies from binaries.

R cannot find g77

I am trying to install from Cran the R package "fGarch", using install.packages('fGarch') I am on Ubuntu, I have r-base-dev and r-base-core installed.
But the install fails because:
77 -fno-optimize-sibling-calls -fpic -g -O2 -fdebug-prefix-map=/build/r-base-ttHamR/r-base-4.0.2=. -fstack-protector-strong -c dist.f -o dist.o
/bin/bash: 77: command not found
/usr/lib/R/etc/Makeconf:190: recipe for target 'dist.o' failed
make: *** [dist.o] Error 127
I have gfortran, gcc, g++. I also have something called "f77".
which f77
/usr/bin/f77
But nothing simply called "77". I do not understand what R is trying to call with "77".
I also installed the package from apt-get, but this then returns an error in R saying the version is too old and I should reinstall it.
Thank you for any help.

installing venneuler and/or rJava R package

I'm trying to install the venneuler R package on linux.
Running: install.packages("venneuler") gives this error:
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package ârJavaâ
* removing â/home/nruns/R/rJavaâ
Warning in install.packages :
installation of package ârJavaâ had non-zero exit status
ERROR: dependency ârJavaâ is not available for package âvenneulerâ
* removing â/home/nruns/R/venneulerâ
Warning in install.packages :
installation of package âvenneulerâ had non-zero exit status
The downloaded source packages are in
â/tmp/RtmpjiRTHN/downloaded_packagesâ
Trying to install the rJava package produces the same error.
So I then run R CMD javareconf as suggested and get this error:
trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -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 conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
#include <jni.h>
I updated java using:
sudo yum install java-1.8.0-openjdk
which completed fine but am still getting the same error trying to install venneuler
Any idea?
For rjava try installing following packages. It helped me
libbz2-dev
libpcre3-dev or libpcre2-dev
liblzma-dev
sudo apt-get install packagename

R - Error installing Devtools in Windows

I'm reasonably new to R, and to stackoverflow, so apologies if I have not provided sufficient detail in my question below. Happy to provide more info if required
I run Windows 7 Professional (64 bit) and have R version 3.0.2 installed.
When I try to install devtools, I obtain
library(devtools)
Warning message:
package ‘devtools’ was built under R version 3.0.3
build_github_devtools()
"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" --vanilla CMD SHLIB foo.c
gcc -m64 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG
-I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -std=gnu99 -mtune=core2 -c foo.c -o foo.o gcc -m64 -shared -s -static-libgcc -o foo.dll tmp.def foo.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.2/bin/x64 -lR Downloading devtools from https://github.com/hadley/devtools/archive/master.zip
"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" --vanilla CMD INSTALL
"C:\Users\AppData\Local\Temp\Rtmp8yGaPd\devtools-master" --build
installing to library 'C:/Users/AppData/Local/Temp/Rtmp8yGaPd/file1afc11f24d1b'
ERROR: dependencies 'rversions', 'git2r' are not available for package
'devtools'
removing 'C:/Users/AppData/Local/Temp/Rtmp8yGaPd/file1afc11f24d1b/devtools'
Error: Command failed (1)
I've searched for help on dependencies rversions and git2r but no luck so far.
Can anybody help please?
This is information about git2r
The following devtools installation information comes from devtools:
Make sure you have a working development environment.
Windows: Install Rtools.
Install the release version of devtools from CRAN with install.packages("devtools").
Windows:
library(devtools)
build_github_devtools()
Restart R before continuing
install.packages("devtools.zip", repos = NULL, type = "source")
Remove the package after installation
unlink("devtools.zip")

How can I install topicmodels package in R?

I am trying to install the package called topicmodels in R and I have not had success. Here's what I have tried...
Action:
Install the package using install.packages("topicmodels")
Result:
package ‘topicmodels’ is available as a source package but not as a binary
Warning in install.packages :
package ‘topicmodels’ is not available (for R version 3.1.0)
So there I said okay let's install from source
Action:
install.packages("/Users/my_name/Downloads/topicmodels_0.2-1.tar.gz",repos=NULL,type="source")
Result:
* installing *source* package ‘topicmodels’ ...
** package ‘topicmodels’ 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 cokus.c -o cokus.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 common.c -o common.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 ctm.c -o ctm.o
ctm.c:29:10: fatal error: 'gsl/gsl_rng.h' file not found
include gsl/gsl_rng.h
1 error generated.
make: *** [ctm.o] Error 1
ERROR: compilation failed for package ‘topicmodels’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/topicmodels’
Warning in install.packages :
installation of package ‘/Users/me/Downloads/topicmodels_0.2-1.tar.gz’ had non-zero exit status
So then I researched this gsl thing and came upon this link. And for the moment I thought all of my problems were gone and when I finally follow these directions. I get the following error (in the terminal)...
Warning in untar2(tarfile, files, list, exdir, restore_times) :
using pax extended headers
ERROR: cannot extract package from ‘topicmodels.tar.gz’
First of all you have to install gsl. Once you have that installed you can try to install the R package. You can download gsl from here (there you can pick the latest version gsl-latest.tar.gz). Once it's been downloaded, install it by doing the following:
Decompress the downloaded file (in my case the "latest" file contained this version: gsl-1.16)
Open the "Terminal"
Then (using the Terminal), move inside the folder that you created on step 1. In my case I had the file on the folder called "Downloads", so I moved to the newly created folder by doing:
cd Downloads/gsl-1.16
Once you are within that folder run the following commands (in order):
./configure
make
sudo make install
After doing it you won't get the previous error saying fatal error: 'gsl/gsl_rng.h' file not found, so you can try again the installation.
Now go back to your R environment (e.g., RStudio) to try again to install the package by doing:
install.packages("PATH_TO_TOPIC_MODELS.tar.gz", repos=NULL, type="source").
I had the same problem, and after doing this I got the R package correctly installed, I hope it also works in your case.
If you already using homebrew. It is better and faster to fix with variables than installing gsl manually from source.
Install gsl with homebrew brew install gsl
Edit ~/.R/Makevars and add.
PKG_LIBS=-L/usr/local/opt/gettext/lib
CFLAGS=-I/usr/local/opt/gsl/include
LDFLAGS=-L/usr/local/opt/gsl/lib -lgsl -lgslcblas
If you are using Linux based on Debian, that's my solution:
Using terminal run sudo apt install gsl-bin libgsl-dbg libgsl-dev libgsl25 libgslcblas0;
Then, using R console, run install.packages("topicmodels",dependencies =T);
Enjoy!!

Resources