Are packages deleted when upgrading R on Linux? I would prefer to just use the default package installation directory, instead of setting up a custom directory.
I'm aware I can setup a custom directory in the following manner:
cat >> ~/.Renviron
R_LIBS=/data/Rpackages/
I just wonder what happens if I don't issue the command above? Will packages be wiped every time I issue the command
sudo apt-get update && sudo apt-get upgrade
, and as a consequence R gets updated to the latest version?
#Jason, when you are doing sudo apt-get update && sudo apt-get upgrade, it just upgrade packages that have a new version in your list of repositories. There is no reason it will modify R packages already installed.
I'm also running Linux and R and the only time I have to re-install R packages is when I re-install my system. My R packages are installed by default in /usr/local/lib/R/site-library
Related
We followed instructions here - https://rtask.thinkr.fr/installation-of-r-4-0-on-ubuntu-20-04-lts-and-tips-for-spatial-packages/ - to uninstall R:
sudo apt-get purge r-base* r-recommended r-cran-*
sudo apt autoremove
sudo apt update
...seems to have worked because when we run R in command line we get -bash: /usr/bin/R: No such file or directory. However, when we try to install R using:
apt install --no-install-recommends r-base
...version 3.6.3 is installed, not version 4.0 or 4.1. Here is our machine type.
What can we do to get R version 4.1.0 (preferred) installed on our machine? I am worried that, perhaps it is not possible as if it were, v4 would be the default rather than v3... might it be the case that 16.04 is too old for R v4?
Edit: followed the instructions in the comment below, but ran into the following issue:
For whatever reason, Amazon moved R to the so-called "Extras Library" so you can't install R using sudo yum install -y R anymore. Instead, you have to do sudo amazon-linux-extras install R3.4. As a result, I can only install R 3.4.3 when the newest stable release is 3.6.1, and so many R libraries can't even be installed because the version is too low. Is there any good and clean way to install the latest version of R and skip Amazon's package manager? Thanks!
Use amazon-linux-extras which installs R4.0.2:
amazon-linux-extras install R4
You may need root:
sudo amazon-linux-extras install R4
I've tried setting up R 3.6.x on a docker container that uses the amazonlinux image. My approach was to get the R source file from the below link and install from source
cd /tmp/
wget https://cloud.r-project.org/src/base/R-3/R-3.6.3.tar.gz
tar -zxf R-3.6.3.tar.gz
cd /tmp/R-3.6.3
./configure --without-libtiff --without-lapack --without-ICU --disable-R-profiling --disable-nls
make
make install
you will need to yum install some dependencies, like 'make', which doesn't seem to come with aws amazonlinux docker image (which i think mirrors the EC2 instance AMI image you are referring to).
The above kind of worked for me in that i had a working R3.6 installation, but it didnt allow me use it with rshiny server, so i'm reverting to the shipped 3.4.3 version.
tl;dr: you'll probably have to manually download the source files and install the desired R version from source, and throw in some build dependencies as well.
Try this on Amazon Linux 2
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install R
Amazon Linux 2 Image contains extras library that can be used as well. Follow the guide here.
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-install-extras-library-software/
sudo amazon-linux-extras enable R3.4
sudo yum clean metadata && sudo yum install R3.4
Since yesterday everything was all right because I used openCPU with R 3.4.4 . Today I tried to install in a fresh ubuntu 16.04 system the R 3.5.1 because I had a problem with a package. So what I did is following:
# Repos for R3.5.1
sudo add-apt-repository ppa:marutter/rrutter3.5
sudo add-apt-repository ppa:marutter/c2d4u
# Repos for opencpu
sudo add-apt-repository -y ppa:opencpu/opencpu-2.0
sudo apt-get update && sudo apt upgrade
# Installs OpenCPU server
sudo apt-get install -y opencpu-server
Everything seemed alright until I tried to visit the http:/ip/ocpu/test and the page never loaded. Then I searched into apache's errorlog
Error: package ‘unix’ was installed by an R version with different
internals; it needs to be reinstalled for use with this R version
From directive RSourceOnStartup on line 7 of
/etc/apache2/sites-enabled/opencpu.conf. Using locale: en_US.UTF-8
Error: package ‘unix’ was installed by an R version with different
internals; it needs to be reinstalled for use with this R version
From directive RSourceOnStartup on line 7 of
/etc/apache2/sites-enabled/opencpu.conf.
I then open an R session and tried to load the unix library which is loaded as expected and without any problem.
Any idea? Is there a conflict between opencpu and R 3.5.2?
Actually, openCPU has its own library which located at /usr/lib/opencpu/library and those packages needed to be recompiled. So I did the following:
pkgs <- as.data.frame(installed.packages(lib.loc="/usr/lib/opencpu/library/"))
pkgs <- as.character(pkgs$Package)
install.packages(pkgs, lib="/usr/lib/opencpu/library/")
and now everything seems to be working.
I am learning to use RSelenium in an EC2 instance, and I found this handy guide on doing so - https://rpubs.com/grahamplace/rselenium-ec2 - however the guide focuses on an Ubuntu instance and I am using an Amazon Linux Instance. In order to install RSelenium, the guide says I must externally (outside of R but ssh'd into my EC2 instance) install the packages xml (XML i think, case sensitive) and RCurl. The guide's relevant lines of code are:
sudo apt-get install r-cran-xml
sudo apt-get install r-cran-RCurl
however, since I'm in an Amazon Linux instance, I tried:
sudo yum install r-cran-xml
sudo yum install r-cran-RCurl
for which I get the following error:
No package r-cran-RCurl available.
Error: Nothing to do
Note: I was successful in installing R on my machine (my instance), and I am able to simply type R to launch R in the EC2 instance.
Note2: install.packages('XML') and install.packages('RCurl') with R launched do not work either.
Any help appreciated with this, thanks!
the amazon linux R package has a different name:
sudo yum install -y R
then you tried (in R) install.packages(c('XML','RCurl')), but the installation failed.
as you discovered and describe in the comment below, you needed to install an additional amazon linux package, libxml2-devel, in order to install.packages('XML') successfully.
this is what I get when I run sudo yum install -y R
No package R available.
Error: Nothing to do
R is available in Amazon Linux Extra topic "R3.4"
To use, run
sudo amazon-linux-extras install R3.4
Learn more at
https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras
For some reason, I could not install the rJava package without root privilege (using sudo R and then install.packages('rJava')). It should have solved my problem, however I can only use this package when launching R with sudo R. If I launch it without sudo, R will act as if this package is not installed.
I tried looking at /usr/local/lib/R/site-library, every package belongs to my user and group "staff" except this one, that belongs to root and staff. The rights for every package are rwxrwxr-x and I am in group staff, so I should have all the permissions I need. In addition, I tried changing the owner of the rJava folder to my user and it didn't change anything. Do anybody have any idea why rJava is not recognized if I start R without sudo?
Thanks!
I also had issues installing rJava so I'll outline the steps I took to fix it even though it may be specific to my system. There's at least a chance it will work for you too.
Remove rJava and openjdk:
sudo apt-get purge r-cran-rjava
sudo apt-get purge openjdk-7-jre
Install oracle java:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Reinstall rJava
sudo apt-get install r-cran-rjava
After that everything was hunky-dory. glmulti installed fine as well.
Try unsetting the JAVA_HOME environmental variable before starting R:
unset JAVA_HOME