Saturday, February 12, 2011

Installing R on Amazon Linux

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.
  • How do I unzip this? Googled, found:
tar xf R-2.12.1.tar.gz
cd R-2.12.1

  • 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
  • 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++
  • Another error message! I need a fortran compiler. In the search above, I saw gcc-gfortran, so:
sudo yum install gcc-gfortran
  • 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
  • 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!


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


  1. You don't say which Linux you are using. I've been playing on EC2 for the last few weeks and was able to install R very easily on a Ubuntu 10.10 64 bit machine.

  2. "Amazon Linux" seems to be their own special flavor.

    I don't think I was able to run Ubuntu on a micro instance. (I want to leave it running all the time, so this was my goal.)

  3. Thanks for posting this -- it was a lifesaver. I think I solved the X11 library problem -- (perhaps by installing more than I needed, but nevertheless):

    sudo yum install libX11-devel.*
    sudo yum install libICE-devel.*
    sudo yum install libSM-devel.*
    sudo yum install libdmx-devel.*
    sudo yum install libx*
    sudo yum install xorg-x11*
    sudo yum install libFS*
    sudo yum install libX*

  4. Please consider It's awesome.

  5. It's also worth noting that you should add

    sudo yum install make

    The Amazon Linux doesn't seem to include this either.

  6. Thanks madcoverboy! I could swear that 'make' was already there the first time I tried this, but probably I'm wrong--just launched a new server, and it's not.

    Thanks Ed! After that, are you able to run R with windowing?

  7. Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work.

  8. At the point when the thing sells, you at that point need to deal with bundling and transporting the thing to the purchaser, after which you will affirm by means of Amazon that the thing has been dispatched so the purchaser can be informed.Ecom Income Blueprint

  9. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here. aws training in chennai