OpenCPU with R 3.5.1 - r

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.

Related

Debian dependencies for some R Packages

I'm about to install a R environment on my debian Debian GNU/Linux 11 (bullseye).
I first simply ran
sudo apt-get --assume-yes install r-base
which worked. However, when installing some packages with install.packages("..") like keyring, lintr or usethis it requires me to install some debian libraries, e.g. libsodium-dev, libxml2-dev, r-cran-gert, libgit2-dev.
After installing these libs, everything worked fine. However, I was wondering if there is any way to pre-install all these debian libraries, e.g. with something like sudo apt-get install r-build-tools so that when I clear my setting and restart the installation process, I don't have to install required debian libraries manually.
Does s.th. come into your mind?

Cannot install R - Unable to correct problems, you have held broken packages

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:

Are packages deleted when upgrading R on Linux?

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

R & RStudio Installation on AWS EC2 Linux AMI - latest version of R

Amazon provides a clear installation guide for launching a micro instance and having R & RStudio installed. The guide can be found here: https://aws.amazon.com/blogs/big-data/running-r-on-aws/
Unfortunately this installs an older version of R. (3.2.2) which provides issues for certain packages, like slam, as they require an R version > 3.3.1
In the guide for the step to change the user data they provide the below script which covers the installation of R & RStudio. How do I change the script to install the latest version of R?
#!/bin/bash
#install R
yum install -y R
#install RStudio-Server
wget https://download2.rstudio.org/rstudio-server-rhel-0.99.465-x86_64.rpm
yum install -y --nogpgcheck rstudio-server-rhel-0.99.465-x86_64.rpm
#install shiny and shiny-server
R -e "install.packages('shiny', repos='http://cran.rstudio.com/')"
wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-1.4.0.718-rh5-x86_64.rpm
yum install -y --nogpgcheck shiny-server-1.4.0.718-rh5-x86_64.rpm
#add user(s)
useradd username
echo username:password | chpasswd
Thanks
Try this:
# Install r-base
yum install r-base
# Install newest version of R from source
wget https://cran.r-project.org/src/base/R-3/R-3.4.0.tar.gz
./configure --prefix=/home/$user/R/R-3.4.0 --with-x=yes --enable-R-shlib=yes --with-cairo=yes
make
# NEWS.pdf file is missing and will make installation crash.
touch doc/NEWS.pdf
make install
# Do not forget to update your PATH
export PATH=~/R/R-3.4.0/bin:$PATH
export RSTUDIO_WHICH_R=~/R/R-3.4.0/bin/R
I ripped this from an ubuntu R install how-to: http://jtremblay.github.io/software_installation/2017/06/21/Install-R-3.4.0-and-RStudio-on-Ubuntu-16.04

Install shiny on remote Debian machine with R version 3.1.1

I am trying to host an shiny app on an remote Debian machine. Yet, i have encountered an R version issue when installing shiny package. I will basically walk through the steps that I took in the process:
After SSH into the VM, I install and update the r-base:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
The latest version I can get for R is 3.1.1. Then, I was trying to install "shiny" package as root by the following command:
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
Then, I was getting the error message like:
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib
Warning message:
package ‘shiny’ is not available (for R version 3.1.1)
Is there any work-around on this issue? Such as starch the apt-get to install the latest R version rather than 3.1.1? Or possibly install shiny from a Github repo? Please help! Thanks!
You should be able to get the R package yourself, rather than using apt-get. This way you can choose which release to install. For example:
wget http://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz
tar zxvf R-3.2.2.tar.gz; cd R-3.2.2/
./configure; make;
sudo make install
Then you can get shiny through the terminal as well, rather than within R:
wget https://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz
sudo R CMD INSTALL shiny_0.13.2.tar.gz
credit to Huiong Tian, from whom I learned this a while back:
http://withr.me/install-shiny-server-on-raspberry-pi/

Resources