Condensed from this post (and comments) on David Chudzicki’s blog, tweaked, and updated for R-2.13.1.
Assumes you’re starting with a virgin “Amazon Linux” AMI. I picked “Basic 64-bit Amazon Linux AMI 2011.02.1 Beta” (AMI Id: ami-8e1fece7) because it was marked as free tier eligible on the “Quick Start” tab of AWS’s “Launch Instance” dialog box:
$ sudo yum -y install make libX11-devel.* libICE-devel.* libSM-devel.* libdmx-devel.* libx* xorg-x11* libFS* libX* readline-devel gcc-gfortran gcc-c++ texinfo tetex $ wget http://cran.r-project.org/src/base/R-2/R-2.13.1.tar.gz $ tar zxf R-2.13.1.tar.gz && cd R-2.13.1 $ ./configure && make $ # make coffee... or finish your PhD thesis... (yes, it takes that long) [...] $ # finally, if all is well: $ sudo make install $ cd $ R --version R version 2.13.1 (2011-07-08) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under the terms of the GNU General Public License version 2. For more information about these matters see http://www.gnu.org/licenses/.
As always, refer to the Installation and Administration manual for details and options.
If you want to install RCurl, or anything which depends on it like twitteR, you’ll need to install libcurl & friends first:
$ sudo yum -y install libcurl libcurl-devel
July 9, 2011 at 6:51 AM
To me, there is value-added in the Debian / Ubuntu builds so I tend to recommend *against* the ‘configure; make’ step. In any event, Debian got R 2.13.1 yesterday and Ubuntu builds of R 2.13.1 are already on the CRAN site so there is no need to rebuild, especially if you feel that the builds takes so long.
July 9, 2011 at 8:43 AM
I would love to hear more about what goes into the Debian/Ubuntu builds. I have used RHEL and CentOS in production for years, and am beginning to feel like the only one who hasn’t made the switch to Ubuntu yet.
I’m trying out Amazon Linux on their first-year-free plan. It has rpm and yum (and no apt), so it looks like RH to me, but I noticed that the last R build for any RedHat was of 2.10.0 back in 2009. I guess there’s no demand for RH binaries. Wow — things have changed!
I found what looks like a great AMI for scientific computing which Drew Conway make by adding a bunch of stuff, including R and Python libraries, to a Ubuntu 10 base from MIT’s STARDEV group. But it can’t be launched in a “micro” instance, so isn’t free tier eligible.
If anyone has a suggestion for a good Ubuntu AMI which can run in a micro instance, I’m all ears. When I just looked, there are 1,296 public Ubuntu AMIs to wade through.
July 14, 2011 at 10:19 AM
I’m following your instructions, but when I type the command “R”, I receive bash: r: command not found.
July 14, 2011 at 10:51 AM
You’re not giving me much to go on.
If the error was
bash: r: command not found., is it possible you tried to run lower-case “r” instead of upper case “R”?
Otherwise, it sounds as if it didn’t install. Did you notice any error messages? What happened when you typed
sudo make install? Did it build the R executable correctly in your working directory (e.g.,
R-2.13.1/bin/R)? If so, does it run?
July 14, 2011 at 10:55 AM
I actually installed it on a 32-bit machine (not sure if that would make a difference).
I’ll try again on a 64-bit Amazon AMI and get back to you if I get the same message. I did use a capital R as well. I’m installing this using a putty interface that connects to my instance. I’ve had the same problems before, and I have no idea why it may be happening. I’m pretty green when it comes to Linux/Unix, so I appreciate the feedback.
July 14, 2011 at 12:03 PM
Alright, so I just copied your instructions verbatim (copy + paste) on a brand new Amazon AMI x64 instance. I logged into the machine with PuTTy, then logged in as ec2-user, then did “sudo su” for root access.
I followed the instructions to a T, but still received the same error.
Any thoughts? I can always load up a pre-made image that contains R, but I like the feeling of actually getting things working myself.
July 14, 2011 at 9:40 PM
Compiling can be satisfying… or frustrating. I encourage you to learn about what each step does.
If the ‘configure’ step completes successfully — do you see any error messages? — ‘make’ is the critical step during which all the code is compiled. If it runs successfully — again, look carefully for any error messages — you should find a working R executable in a ‘bin’ directory. Is it there? Does it run?
Just like any diagnostic process, just break it down, step by step.
July 15, 2011 at 9:38 AM
Try typing “./R” instead. You may not have the current working directory in your search path.
July 15, 2011 at 9:46 AM
Good point, David. Or “
bin/R” since you’re probably in the distribution’s top-level directory.
July 15, 2011 at 10:11 AM
Well, I got it up and running, Jeffrey. Just in case anyone else has this problem, I logged into the Amazon AMI as ec2-user, then I would type “sudo su” to go to root. I left that step out and voila, I now have R on my image.
Thanks for the guidance!
July 15, 2011 at 11:18 AM
Fantastic — glad it worked!
In general, I do as little as root as possible (since you can really hose a machine
rm -fr /style…). I did all the configuring and building as ec2-user then only switched to root for the installation.
July 15, 2011 at 11:22 AM
…and now that you know how to build it, you can test out some of the new options (like pre-compiling all the R packages to bytecode) and let us know if it’s worth it (or even works)!
July 25, 2011 at 4:38 AM
you were right! I had time to get a coffee and some tea and then some beer and then some lunch and it was still running the make command. hopefully i am good to go by dinner.
excellent post though….really helpful!
July 25, 2011 at 10:20 AM
Thanks — good luck!
August 2, 2011 at 10:54 AM
Hi everybody, I’m R windows user, however I neen use it from a terminal consola ssh, and I have troubles for running R and load work area, may be someone can help me with the most common commands for this case.
August 3, 2011 at 4:34 PM
Are you looking for R commands to load a saved workspace? (Try ?load in R).
Are you ssh’ing into a linux box? Are you looking for help with linux commands? What sort of problems, specifically, are you having?
October 18, 2011 at 12:18 PM
Hi Jeffrey, Im using secure shell client consola for windows. I was able to overcome the problem of loading the workspace from the console, but the real problem is that the algorithm with simulations in the cluster have the same problem with my personal machine (insufficient RAM). ¿Is it necessary to include special commands in scripts to work in cluster, or should I install some additional package?.
Thanks for your help
October 20, 2011 at 9:42 AM
The terminology around EC2 can be confusing. While everything runs on Amazon’s cluster(s), if you’re just using EC2, you’re getting a single virtual server with a fixed amount of RAM. If you need more RAM (or CPU), they offer different instance sizes: from 613MB in a “micro” instance up to 68.4 in a “High-Memory Quadruple Extra Large Instance” (see http://aws.amazon.com/ec2/instance-types/). Of course, bigger instances cost more than smaller ones.
There are a number of ways to split up your work onto multiple machines (virtual or otherwise), if your simulations are amenable to parallelization. If you’re interested in that kind of cluster, the High-Performance and Parallel Computing CRAN task view should give your Googling a good starting point.
JD Long has come up with a very novel use of Amazon’s Elastic MapReduce service. JD’s an agricultural economist working in the insurance industry and needs to run a bunch of monte carlo simulations every month. EMR is Amazon’s hosted Hadoop service which is intended for big data. Nevertheless, JD uses it to spin up a bunch of nodes into a temporary cluster to execute his monthly simulations. He has developed and released the ‘segue’ package which I wrote about earlier this year: https://jeffreybreen.wordpress.com/2011/01/10/segue-r-to-amazon-elastic-mapreduce-hadoop/
Hope that helps,
October 31, 2011 at 11:50 AM
October 2, 2011 at 2:53 PM
hey, I am back.
My terminal kinda hangs for some reason. any tips on how long i should wait before i check if R is installed? (esp after the configure and make commands)
December 21, 2011 at 1:15 PM
This worked like a charm. Thank you!
April 16, 2012 at 11:49 AM
I was just gearing up to grunt through the installation but you spared me the trouble. Worked great.
July 23, 2012 at 10:12 PM
Reblogged this on Human Mathematics.
August 18, 2012 at 10:03 AM
I have since given up on Amazon Linux. There are a number of good CentOS AMIs and, thanks to the EPEL repository, installing R is once again the 1-line exercise it should be!
July 23, 2012 at 10:22 PM
My girlfriend said
rvmtook forever and a half to install on an (ubuntu) EC2 AMI as well. How can these instances be fast enough to serve up the entire twittersphere and take so long to install programs?
July 24, 2012 at 3:30 PM
So a year later, Amazon now has 64-bit Ubuntu 12.04 instances.
sudo apt-get install r-base-coretook about a minute.
ubuntu@ip-10-85-33-229:~$ R --version
R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
July 24, 2012 at 3:31 PM
And I mean free-tier-eligible micro instances of Ubuntu 12.04.
August 18, 2012 at 10:01 AM
That is progress. I’ve always been a Red Hat guy myself, so I tried to use Amazon Linux. This was last year, so it may be fixed by now, but there was a problem with some package dependency (related to Tcl/Tk, I think), so there was no easy way to install R.
I now use CentOS images insteaf, and don’t compile anything anymore 🙂
January 28, 2013 at 4:14 PM
The Amazon Linux AMI added support for the R language in October – you can now simply “yum install R”!