Notes on Ubuntu (Linux) computing

Brief notes on installation, setup and other tasks in the Ubuntu world

Installing R on Ubuntu 12.04

with 13 comments

I install R using the instructions at (direct link to instructions). At the website, click ‘Download R for Linux’ then ‘ubuntu’ to get the most up-to-date instructions. Following these instructions, my process was as follows:

Add the repository, using the CRAN server of your choice (I use UCLA here) and the appropriate Ubuntu version (I use precise for Ubuntu 12.04):

sudo add-apt-repository "deb precise/"

For security, get the key and add it to your keyring (NOTE: the CRAN website says that some people are having issues with this step — if the commands here do not work for you, check there for latest information):

gpg --keyserver --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -

Next, update and install (the documentation says you might want to install r-base-dev as well, but I found this package is already included using the commands below):

sudo apt-get update
sudo apt-get install r-base

Installing packages

To install package not in the base set, use the following commands

sudo R

Now, inside R, install package packagename with

install.packages('packagename', dep = TRUE)

Note — the quotes around the packagename ARE needed.

Updating packages

Again, start R with sudo:

sudo R

Now, inside R, update packages with

update.packages(ask = FALSE)


I do much of my coding in Geany irrespective of the language. However, the rstudio IDE/GUI is nice and available on all major platforms (Win,MAC,Linux) making it useful for teaching R.

  • Download the debian package from
  • I downloaded RStudio 0.97.237 – Debian 6+/Ubuntu 10.04+ (64-bit) — this is actually a file: rstudio-0.97.237-amd64.deb
  • If all dependencies are installed (output will complain if not), install rstudio-0.97.237-amd64.deb file using
    sudo dpkg -i rstudio-0.97.237-amd64.deb

    I got a complaint about libjpeg62 and installed is using:

    sudo apt-get install libjpeg62

    followed by the installation of the deb file, as shown above.


Written by Chris S

December 9, 2012 at 10:51 pm

Posted in R, Ubuntu 12.04

Tagged with , ,

13 Responses

Subscribe to comments with RSS.

  1. Good post!


    April 14, 2013 at 9:16 pm

  2. Thank you so much, this is the only instruction that I understood and worked for me..


    September 16, 2013 at 3:09 pm

  3. This thing works like a charm buddy on my Ubuntu 12.04…..many thanks…..


    December 11, 2013 at 11:36 am

  4. many thanks
    i’m a rooky so pleaaaaaase how and when to use R ??
    i read about it in block design

    Ahlam Ahlem

    January 18, 2014 at 8:44 pm

    • Hi Ahlam,

      You ask a very open-ended question. Most people use R for statistics applications — analyzing data using regression, classification, etc. However, it can be used a general programming language if you like.

      I’d suggest searching for R tutorials online to get a sense of what can be done and how to get started.


      Chris S

      January 23, 2014 at 7:13 pm

      • hi Chris
        all thanks for your reply
        does R is open source or not ?
        if it is i need iR in classification of set of elements in subsets but i need to add some condition in this classification like that 2 elements for exemple x and y should not be together in the same set

        is it possible with R or not ? i try to google it but i did not find from where i should start

        many thanks

        Ahlam Ahlem

        January 24, 2014 at 6:34 pm

  5. I installed R using above instructions. However, it installs the 32 bit R and I want to install 64 bit
    What change in the command is needed to install 64 bit R


    July 20, 2014 at 6:25 pm

    • Hi Suahs,

      These instructions were done on Ubuntu 12.04 using a 32bit setup. I have not installed R on 64 bit Ubuntu 14.04 yet.

      The instructions that I used are at cran:

      They seem to indicate that both 64 and 32 bit versions are available using the same basic approach — I think the 32 vs 64 bit should be automatically detected. Make sure that you are using “trusty” instead of “precise” to get Ubuntu 14.04 versions (which I assume you want). Again, consult the link above.

      I hope that helps,


      Chris S

      July 22, 2014 at 12:14 am

  6. Reblogged this on Abdel Rahman Farag Hegazi and commented:
    Installing #R #Rstudio on #Ubuntu, pretty well explained!

    Abdel Rahman Farag Hegazi

    February 9, 2015 at 12:58 am

  7. Excellent tutorial, got R and Rstudio working the first time itself. Rare occurrence 🙂

    Ananya Raval

    May 8, 2015 at 4:32 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: