How to upgrade R version on AWS EC2 instance? - r

Quite surprisingly it's hard to find a workable solution around this.
I have an EC2 instance launched with Ubuntu 18.04 distribution.
I do sudo-get install r-base but the installed R version is R3.4
I've followed the steps here below where it asks to edit the source.list file
https://cran.r-project.org/bin/linux/ubuntu/README.html#installation
However, AWS declines the update as the source link is not secured.

Have you made sure you succesfully added the public key to the system?
This has worked for me fine in EC2 Ubuntu 18.04 to update to R 3.6.1. I also followed instructions given in https://cran.r-project.org/bin/linux/ubuntu/README.html#installation.
First, add the public key in the documentation´s "Secure APT" section. Run this in terminal:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
Next, add modify your file /etc/apt/source.list by entering this command:
$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
Once that is done, enter this command and double check if AWS has not declined the update
$ sudo apt update
Finally, run this to get updates installed
$ sudo apt install r-base r-base-dev
I found this resource to be very helpful:
https://www.charlesbordet.com/en/shiny-aws-3/#how-to-install-shiny-server

I ended up using AMI from this website
louisaslett.com/RStudio_AMI/
It has some pre-builts libraries and installations.

Related

How to upgrade IRKernel in Ubuntu?

On Ubuntu 18.04 LTS, while working R in JupyterNotebook (without Anaconda), the IRKernel is reading the R version 3.4. For using some packages like cowplot it is necessary to have at least version 3.5.
Basically, two steps should be taken:
Update R. These and that answers were a guideline.
Update IRKernel. The offical IRKernel instructions for Linux were useful.
Next, is described the complete procedure
1. Add Key to server
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
2. Add Entry to sources.list
echo 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/' | sudo tee -a /etc/apt/sources.list
Depending on the linux you're using you should change, for example, bionic by xenial or cosmic, check out https://cran.r-project.org/bin/linux/ubuntu/README.html
3. Update Programs
According to the instructions in the above link, we should do the following:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
4. Update /.local/share/jupyter/kernels/ir
type R in the console and follow the next steps according to this link
# In the console
R
# Inside R
install.packages(c('repr', 'IRdisplay', 'IRkernel'), type = 'source')
getRversion() # to verify the new R version
IRKernel::installspec()
This should show the following message:
[InstallKernelSpec] Removing existing kernelspec in /home/user_name/.local/share/jupyter/kernels/ir
[InstallKernelSpec] Installed kernelspec ir in /home/user_name/.local/share/jupyter/kernels/ir
As a final remark, you should remove the older version of R, which you can find in ~/R/x86_64-pc-linux-gnu-library, where you will now have two directories with two different versions or R (remove the older one).

Log in RStudio with AWS EC2 instance

I managed to follow all the steps to create EC2 instance and install R Server on it.
But now when I go to RStudio to connect (which looks something like "ec2-[Public IP]-.eu-west-3.compute.amazonaws.com:8787")
I am asked a username and a password but I did not configure any:
I tried rstudio (username) and rstudio (password) but it does not work.
Anyone knows how I can find the username and the password to connect?
Thanks.
M
If this is using the AMI from http://www.louisaslett.com/RStudio_AMI/, the default password recently changed to the instance ID of the EC2. A code starting with i- and 17 alphanumeric characters, for example.
Username is still rstudio.
You can create a user/password in Linux and use it to log in
#add user(s)
useradd username
echo username:password | chpasswd
here is a detailed blog from on running R on AWS
I was having the same issue (I believe there is no ubuntu password for an AWS EC2 Instance and R studio requires one).
You can add a new user by typing the following: sudo adduser YOURUSERNAME and follow the terminal instructions (press enter to skip the info you do not want to give). Head over to the IP xxx.xxx.xxx.xxx:8787 and you should be able to log in now.
How to install R studio 3.4.4, upgrade to 3.6.0 and add a username (Ubuntu 18):
sudo apt update
sudo apt-get install -y r-base r-base-dev
sudo apt install gdebi-core
wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-1.2.1335-amd64.deb
sudo gdebi rstudio-server-1.2.1335-amd64.deb
sudo chmod 777 -R /usr/local/lib/R/site-library
sudo adduser YOURUSERNAME
#########
# Upgrade R
echo "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/" | sudo tee -a /etc/apt/sources.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y r-base r-recommended r-base-dev
# Rstudio dependency issues (when installing devtools) - I installed from an AWS EC2 account so I need to change my root password.
sudo passwd root
su root
apt-get -y build-dep libcurl4-gnutls-dev

Getting this error on Ubuntu 16.04, Unable to locate package dotnet-dev-1.0.0-preview2

I followed the instruction from this link.
$ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
$ sudo apt-get update
Then while I run this command:
$ sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177
I get the following error:
E: Unable to locate package dotnet-dev-1.0.0-preview2.1-003177
E: Couldn't find any package by regex 'dotnet-dev-1.0.0-preview2.1-003177'
Please help!
I just checked the repository pool and found they have changed their naming convention. In your above command the package name has been entered incorrectly:
dotnet-dev-1.0.0-preview2.1-003177
Where it should be:
dotnet-dev-1.0.0-preview2-1-003177
Notice the - instead of the .. If this is the issue then it is either a mistyped tutorial on the Microsoft site or a change in their naming scheme that hasn't been reflected everywhere.
You need to install HTTPS transport layer security for the apt-get application. The .NET Core repos are https, that is why they are not updated along with the other packages.
Simply type in the terminal
sudo apt-get install apt-transport-https
and your
sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177
should work like a charm! (at least it did for me)
I'd leave this in a comment, or upvote the other comment that mentioned this fix, but because I am new I am not allowed to do any of those things. I just wanted to confirm that that fix worked for me.
make sure you don't get any errors while updating the package list. I had to install apt-transport-https before executing sudo apt-get update.

opencpu cloud server installation guide on ubuntu 16.04

Would anyone know or like to share their note on installing opencpu cloud server on ubuntu 16.04?
I thought it is easy, but we saw many error here and there when following the instructions. I am new to opencpu. And, I don't have much experience on apache and nignx.
Here is the long story:
I created a new and clean ubuntu 16.04 server from microsoft azure vm, and installed opencpu cloud server following:
# Requires Ubuntu 14.04 (Trusty) or 16.04 (Xenial)
sudo add-apt-repository -y ppa:opencpu/opencpu-1.6
sudo apt-get update
sudo apt-get upgrade
# Installs OpenCPU server
sudo apt-get install -y opencpu
The server reported insserv error when running opencpu init script
update-rc.d: error: insserv rejected the script header dpkg
We then did some goolge and fix around, we got apache2 running, but when called:
curl http://localhost/ocpu/info
received 404 error.
FYI, the single user server runs fine.
The solution we found is that opencpu need mod_R to be turned on from apache2:
sudo a2enmod R
You need first to change to dir:
/etc/apache2/mods-available
And, make sure R.load file exists.
After running a2enmod command, should see a link to R.load (R module) in
/etc/apache2/mods-enable
Thank you y g for your question and response .. I had the same problem i try what you have mentioned in your comment but
curl http://localhost/cpu/info
takes along time without no response.
Thank you.
I used opencpu 1.5 works without bugs on ubuntu 16.04
sudo add-apt-repository -y ppa:opencpu/opencpu-1.5
sudo apt-get update
sudo apt-get upgrade
Install R and then install opencpu
sudo apt-get install r-base r-base-dev
sudo apt-get install -y opencpu
Also you should probably install Rstudio for IDE access
sudo apt-get install rstudio-server
To login to R you'll need to make a new user - follow the prompts
sudo adduser myname
Now just to make sure its all working
sudo service opencpu restart
sudo service rstudio-server restart
And try something like to check if its working
curl -L -v localhost/ocpu/library/
which should return a list of packages now installed on Ubuntu like this
Final Screenshot

R studio not working on ubuntu 16.04

I converted to Ubuntu today, but have a problems launching R studio. I installed R through the command prompt like this:
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/">> /etc/apt/sources.list'
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base
I cheked if R was installed proper by typing R and then exiting by q(save="no").
I installed R studio through the command prompt by
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/rstudio-server-0.99.902-amd64.deb
sudo gdebi rstudio-server-0.99.902-amd64.deb
But this doesn't work and i can't find the launch button or open R studio.
Afterwards i tried to remove it and install it through the website but doesn't work either. What should i do?
There is no lauch button -- you connect to port 8787 on the machine running RStudio Server.
In other words, type http://localhost:8787 in the address bar of your browser. You should see a login screen with the RStudio logo. This connects you to your RStudio Server.
If you want to run the Desktop version you need to install the other available .deb package.
For those on Ubuntu 16.10, or who prefer to use the desktop version of RStudio, you may wish to follow the solution posted by Mike Williamson reproduced below:
1) Get the latest R Studio Daily Build here, though note that it's not necessarily stable.
2) Install, chaning the name of the package to the one you downloaded - perhaps easiest if you go to your Downloads directory - and you'll probably find that there are missing packages:
$ sudo dpkg -i rstudio-1.0.124-amd64.deb
3) Download the missing packages (the lack of which causes the installation to fail):
$ wget http://ftp.ca.debian.org/debian/pool/main/g/gstreamer0.10/libgstreamer0.10-0_0.10.36-1.5_amd64.deb
$ wget http://ftp.ca.debian.org/debian/pool/main/g/gst-plugins-base0.10/libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb
4) Install them:
$ sudo dpkg -i libgstreamer0.10-0_0.10.36-1.5_amd64.deb
$ sudo dpkg -i libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb
5) Make sure they don't get over-written at the next software update:
$ sudo apt-mark hold libgstreamer-plugins-base0.10-0
$ sudo apt-mark hold libgstreamer0.10
6) Install RStudio (changing name to the version you downloaded):
sudo gdebi rstudio-1.1.5-amd64.deb
7) Launch RStudio:
rstudio

Resources