Installing R on Amazon Linux

February 13, 2011
By

(This article was first published on David Chudzicki's Blog, and kindly contributed to R-bloggers)

When I wanted to run R (statistical software) on the Amazon "cloud", the first thing I found was this post explaining how to launch an Amazon EC2 "instance" (virtual machine) and pointing to an "image" (contains operating system and whatever else you want) that had Ubuntu and R.

Then I wanted 64-bit R, and it turned out that by far the easiest thing was to launch a Windows instance on Amazon EC2. I googled for an explanation, but it doesn't really need one. You launch a Windows instance, make sure the security group allows RDP, and connect with Remote Desktop. Works very smoothly. I could even connect with my phone.

But now I wanted to run R on a virtual machine which I could (for free) leave running all the time. For this I needed to run Amazon Linux on a "micro" instance, which ruled out both of the above. I launched a micro instance running Amazon Linux, and ssh'd into it.

Okay, now how do I install R?

I'll outline the process I went through. But I also went through a lot more confusion/frustration than I'll describe!

  • Can I use an automatic installer? Apt-get and yum seem to work for various people on the internet. But not for me! Oh well.
  • How do I get a file? Googled, found wget.
wget http://cran.at.r-project.org/src/base/R-2/R-2.12.1.tar.gz
  • How do I unzip this? Googled, found:
tar xf R-2.12.1.tar.gz
cd R-2.12.1

./configure
  • There's an error message! Google the error message to learn I need a C compiler. I had learned earlier that yum is for installing things, and googling reveals that gcc is a C compiler:
sudo yum install gcc
./configure
  • Another error message! Google the message to find that I need a C++ compiler. Maybe something like gcc will help...
yum search gcc
  • Yep! I now see gcc-c++, so I'll install that:
sudo yum install gcc-c++
./configure
  • Another error message! I need a fortran compiler. In the search above, I saw gcc-gfortran, so:
sudo yum install gcc-gfortran
./configure
  • Another error message! Google the message, revealing that I need readline-devel. I still don't know what that is, but this works:
sudo yum install readline-devel
./configure
  • Another error message! Google shows me a post from someone who seems a bit confused, but less confused than I am. Following the advice in that post (which seems like it will get me an incomplete R build, maybe with something related to windowing missing--but I won't be using windows anyway):
./configure --with-x=no
  • It works!

make
PATH=$PATH:~/R-2.12.1/bin/

R

  • Yippeee! I have R now. You can follow these steps, or I think you can use the public AMI I've created, AmazonLinuxWithR_c.

To leave a comment for the author, please follow the link and comment on his blog: David Chudzicki's Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.