How Do You Install R on an Ubuntu Linux Instance of AWS?

Problem scenario
You are running Ubuntu Linux in AWS.  You want to install R. How do you do this?

Solution
(These directions below were adapted from this link.)

Prerequisite
Verify you have 1 GB of RAM.  Run this command:  sudo dmidecode -t 17 | grep Size

If you see 512 MB in the results of the above command, then you will not be able to get R installed.  You will need a different AWS server -- a flavor with at least 1 GB of RAM.  To upgrade the flavor to have more memory, see this posting.  To add virtual memory (aka swap space), see this posting.

Method
1.  Run these four commands:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get -y install r-base

2.  a.  Run this command to enter the R command prompt:  sudo -i R 

2. b.  Note that the ">" sign below is just a reference. Do not type the ">" or space thereafter when you type the command below.

install.packages('txtplot')

2. c.    Enter a selection (e.g., 45 if you are in Texas).  Press enter.

2. d.  Run this command from the > prompt.

library('txtplot')

If there were no errors, then it is working.

Leave a comment

Your email address will not be published.