launching R in AWS EC2 - r

I am trying to launch an R instance in AWS EC2. I have opted for the free tier and use the Amazon Linux AMI. In user data I have specified in the following manner to install R and Rstudio:
#!/bin/bash
# install R
yum install -y R
# install RStudio-Server
wget https://download2.rstudio.org/server/centos6/x86_64/rstudio-server-rhel-1.2.5033-
x86_64.rpm
yum install -y --nogpgcheck rstudio-server-rhel-1.2.5033-x86_64.rpm
yum install -y curl-devel
yum install -y openssl openssl-devel
# add user
useradd forecasting
echo forecasting:testing | chpasswd
However, the R version is not the latest one - how do I modify this code to download the latest version of R?

Using the instructions in this installing R for RStudio link, I think the following might work for Centos 6. Unfortunately I can't check it, but it might give you something to work from.
#!/bin/bash
# install R runtime dependencies
yum install epel-release
# set R version
R_VERSION=3.6.2
# download and install R
wget https://cdn.rstudio.com/r/centos-6/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
yum install -y R-${R_VERSION}-1-1.x86_64.rpm
# install RStudio-Server
wget https://download2.rstudio.org/server/centos6/x86_64/rstudio-server-rhel-1.2.5033-
x86_64.rpm
yum install -y --nogpgcheck rstudio-server-rhel-1.2.5033-x86_64.rpm
yum install -y curl-devel
yum install -y openssl openssl-devel
# add user
useradd forecasting
echo forecasting:testing | chpasswd

Related

Installing R devtools package on WSL

The problem:
I'm trying to install the devtools package for R. I'm using Ubuntu 18.04 LTS on WSL, the Windows Subsystem for Linux.
I'm able to install some packages just fine with a simple call to install.packages() from within R on WSL. However, other packages seem to give me trouble.
None of the following methods I've tried seem to work:
* I've tried installing the package with install.packages().
* I've tried installing from source into /usr/local/lib/R/site-library.
* I've tried installing from source into a personal library.
Error message:
I was recieving an error message like that discussed here, but I was unable to fix the problem by editing unpackPkgZip because it didn't exist.
The Question:
How can I install devtools on WSL?
Solution:
I was able to fix the problem by starting over. I uninstalled Ubuntu and then reinstalled it. With a fresh install of Ubuntu 18.04 I followed these instructions. There are other online tutorials which probably work just fine, but I followed this one. You can ignore the bit about installing an rstudio server and the fsl package if you wish.
# Install R on WSL
sudo apt-get update -qq -y
sudo apt-get install -y wget git
OS_DISTRIBUTION=$(lsb_release -cs)
wget -O- http://neuro.debian.net/lists/${OS_DISTRIBUTION}.us-nh.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
sudo apt-key adv --recv-keys --keyserver hkp://pool.sks-keyservers.net:80 0xA5D32F012649A5A9
sudo apt-get update
sudo apt-get install libopenblas-base r-base
sudo apt-get update -qq -y
sudo apt-get install -y libgit2-dev
sudo apt-get install -y libcurl4-openssl-dev libssl-dev
sudo apt-get install -y zlib1g-dev libssh2-1-dev libpq-dev libxml2-dev
#sudo apt-get install -y libhdf5 # This didn't work.
Now try installing devtools in R.
# Install devtools
install.packages("devtools", repos = "https://cran.rstudio.com/")
Permission error:
If you encounter a permission error like the following...
Warning in install.packages("edgeR") :'lib = "/usr/local/lib/R/site-library"' is not writable Would you like to use a personal library instead? (y/n)
...you need to provide the user with write access to the directory where R packages are installed (see here). Try changing the group ownership of this directory:
# Who has ownership of /usr/local/lib/R/site-library/?
ls -l /usr/local/lib/R/
# drwxrwsr-x 1 root staff 512 Jul 18 21:38 site-library
# Change ownership.
sudo chgrp twesleyb /usr/local/lib/R/site-library/
ls -l /usr/local/lib/R/
#drwxrwxr-x 1 root twesleyb 512 Jul 18 21:38 site-library
# In this case I have write access, but in case you need to add it, try:
# $ sudo chmod g+w /usr/local/lib/R/site-library
You should now be able to install.packages("package").
I'm a linux novice, but I think this is an okay thing to do.
Update:
You can also try following duckmayr's instructions.

Not able to install tm package in R Studio in Fedora-25

I am getting this error and i have tried every other solution related to this given on stackoverflow but still not able to install the package.Please suggest a solution.And how can i install any R package using source on linux?
You can try the following:
In shell:
sudo yum install -y epel-release
sudo yum install glibc-common
sudo yum install -y rpm-build make wget tar libxml2-devel
In R:
install.packages('xml2')
Instructions are adapted from https://github.com/opencpu/opencpu-server/tree/master/rpm#readme
Please let me know if it works.

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

Make apt install packages from a specific repository

Is there any way to have apt install a package from a specific launchpad repository?
I would like to set up a little test server and install all of the 1000+ r-cran-* packages from the cran2deb4ubuntu launchpad repository. As of last month, all packages in this repository are build for R 3.0.1. So I install a copy of R 3.0.1 and then do:
sudo add-apt-repository marutter/c2d4u
sudo apt-get update
sudo apt-get install r-cran-*
However, this will also install all of the r-cran-* packages form universe which are build for R 2.15, and hence will fail to load. Is there an easy way to install the packages only from c2d4u? Or alternatively, is there a way to blacklist the r-cran- packages in universe from apt?
What I ended up doing is simply install all packages and then remove the ones with an old build. I.e.
sudo add-apt-repository ppa:marutter/c2d4u -y
sudo add-apt-repository ppa:marutter/rrutter -y
sudo apt-get update
sudo apt-get install r-bioc-*
sudo apt-get install r-cran-
And then in R:
which(installed.packages()[,"Built"] < 3.0)

Cannot install RStudio on CentOS 6.4

I am trying to install RStudio on Centos 6.4 with an already installed R version.
I got the following error:
error: Failed dependencies:
libcrypto.so.6()(64bit) is needed by rstudio-server-0.97.336-x86_64
libgfortran.so.1()(64bit) is needed by rstudio-server-0.97.336-x86_64
libssl.so.6()(64bit) is needed by rstudio-server-0.97.336-x86_64
Any hint will be highly appreciated.
I fixed this error following this link:
http://jermdemo.blogspot.com.es/2011/08/installing-rstudio-server-on-scientific.html
You have to install some dependencies:
yum install libcrypto.so.6 -y
yum install libgfortran.so.1 -y
yum install libssl.so.6 -y
yum install openssl098e-0.9.8e -y
yum install gcc41-libgfortran-4.1.2 -y
yum install pango-1.28.1 -y
and the tricky one:
wget ftp.scientificlinux.org/linux/scientific/6.0/x86_64/os/Packages/compat-
libgfortran-41-4.1.2-39.el6.x86_64.rpm
rpm -Uvh compat-libgfortran-41-4.1.2-39.el6.x86_64.rpm
and install Rstudio with no-deps flag:
rpm -Uvh --nodeps rstudio-server-0.97.336-x86_64.rpm
rstudio-server verify-installation

Resources