How to install R on Ubuntu 11.04

R can be easily installed on Ubuntu using apt:

Open a terminal window and execute

sudo apt-get install r-base

To install a new package and save the files at /usr/R-libs, first make sure that /usr/R-libs is writeable, then start R:

> install.packages(“package name”, lib=”/usr/R-libs”)

To load the package from /usr/R-libs

> library(“package name”, lib.loc=”/usr/R-libs”)

That’s all

13 Responses to How to install R on Ubuntu 11.04

  1. Charles Mbogo 02.04.2011 at 08:40:39

    Hi Jonas,
    Thank you for the help. I followed them and installed R successfully. Quite new in linux but am learning.

  2. Jan 05.05.2011 at 09:52:04

    Hi Jonas,

    Thanks for your post. Everything is working except that this is currently for R 2.12.1 64bit. I however would like to upgrade to 2.13.0 the current R version but ran into a problem which I described here:
    Any advice on this would be great. thanks.
    http://superuser.com/questions/279088/installing-the-latest-r-version-2-13-0-on-ubuntu-11-04

    • Jonas Ranstam 05.05.2011 at 12:29:13

      Hi Jan,

      Yes, I assume this is due to dependency issues, and this is a problem that can be very frustrating to try to solve. Is the difference between 2.12.1 and 2.13.0 important? Otherwise I would just wait and rely on apt-get upgrade.

      Regards,
      Jonas

      PS. You can download (from http://www.r-project.org/) and install r-base-core_2.13.0-1natty0_i386.deb or r-base-core_2.13.0-1natty0_amd64.deb to run R v2.13.0 on Ubuntu 11.04, but there may be additional problems.

  3. Sakti 25.05.2011 at 22:47:05

    Hi Jonas,

    I currently have R version 2.11.1 but I would like to upgrade to 2.12 to use some packages. I’ve searched around the web and nothing!!! How can I do it???

  4. Sakti 28.05.2011 at 21:21:56

    Thanks so much Jonas, it worked!!!!

  5. Tito Conte 09.09.2011 at 04:00:16

    Hi Jonas,

    I install the R like you saw, but i don’t found the R-libs, or the program…

  6. Jonas Ranstam 10.09.2011 at 09:46:34

    Check that the “multiverse” software is enabled in System > Administration > Synaptic Package Manager and Settings > Repositories

  7. Pingback: How to install R on Ubuntu 11.10 Oneiric Ocelot « Jonas Ranstam's website

  8. dixi 17.01.2012 at 05:46:41

    Hi! im very new to using Ubuntu 11.10 (not a techy as well) and I am trying to install R.
    I am done with the first step. I have a few question:

    “To install a new package and save the files at /usr/R-libs, first make sure that /usr/R-libs is writeable, then start R:” >> how can i make sure that /usr/R-libs is writeable?

    also, “> install.packages(“package name”, lib=”/usr/R-libs”)”, what shall i write in “package name”?

    when i copied that syntax “install.packages(“package name”, lib=”/usr/R-libs”)”, I got an error
    “install.packages(“package name”, lib=”/usr/R-libs”)”

    Can you help me with this please?

    • Jonas Ranstam 17.01.2012 at 08:22:17

      Hi dixi,

      You can read about Linux file permissions here.

      To set write permission to /usr/R-libs for all users using the commandline, first open a terminal window (press the “Ctrl”, “Alt” and “t” keys at the same time). Then run the command: sudo chmod 777 /usr/R-libs.

      Another alternative is to save the package at another folder under your home directory. R will suggest one to you if /usr/R-libs turns out to be unwriteable.

      You can read about the different R-packages here. Look for Download, Packages in the left column.

      • dixi 20.01.2012 at 09:03:20

        Thank you for the response but I still can not follow it. It seems that I do not have R-lib.
        dixi@dixi-System-Product-Name:/usr$ ls -l
        total 200
        drwxr-xr-x 2 root root 69632 2012-01-20 11:03 bin
        drwxr-xr-x 2 root root 4096 2011-11-02 10:44 games
        drwxr-xr-x 38 root root 16384 2012-01-17 12:12 include
        drwxr-xr-x 240 root root 73728 2012-01-20 11:03 lib
        drwxr-xr-x 10 root root 4096 2011-04-26 06:50 local
        drwxr-xr-x 2 root root 12288 2012-01-03 09:44 sbin
        drwxr-xr-x 350 root root 12288 2012-01-17 12:12 share
        drwxrwsr-x 15 root src 4096 2011-12-13 11:45 src

        i checked /usr/lib/R. within the R folder i have lib and library folder. The library folder has a locked icon on it.

        i tried sudo chmod 777 /usr/lib/R/lib and sudo chmod 777 /usr/lib/R/library. then install.packages(“r-cran-boot”,lib=”/usr/lib/R/lib”) or install.packages(“r-cran-boot”,lib=”/usr/lib/R/library”)

        but i get
        bash: syntax error near unexpected token `”r-cran-boot”,lib=”/usr/lib/R/library”‘

        btw, i also check synaptic manager and “multiverse” has a checked on it. The same for restricted, universe and main.

  9. Jonas Ranstam 20.01.2012 at 10:50:37

    If you wish to install the package in the folder /usr/R-libs and this does not exist, just create it.
    Then make the folder writeable as above and install the package again. Note that install.packages(“r-cran-boot”,lib=”/usr/lib/R/library”) is an R-command and should be run in an R console (start R by typing “R” in a terminal window), not at the bash prompt. If you wish to do that, use this is the command:

    R CMD INSTALL r-cran-boot -l /usr/lib/R/library

    To get more information on this subject, type ?INSTALL in an R console.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.