The other day I wanted to install R on Ubuntu. Googling led me to this site, but I found some of them are not up-to-date. In addition, I don’t use Sun-Java but open-JDK. So I needed to change things a little bit.
Below is what I did. Note that I already installed openJDK.
- Add an R repository to /etc/apt/sources.list
- Obtain the public key of Ubuntu repository
- Update the respository
- Install r-base
- Upgrade the repository
- Set java configuration
- Start R environment
- Install JGR inside R environment
First, you need to decide a CRAN mirror close to where you live. The list can be found here. Since I live in Tsukuba Japan, I added the following line to /etc/apt/sources.list
deb http://cran.md.tsukuba.ac.jp/bin/linux/ubuntu lucid/
Below is the format.
deb http://my.favorite.cran.mirror/bin/linux/ubuntu lucid/
The Ubuntu archives on CRAN are signed with the key of “Michael Rutter
” with key ID E084DAB9. You can fetch this key then feed it to apt-key with the following lines.
$ gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
$ gpg -a --export E084DAB9 | sudo apt-key add -
$ sudo apt-get update
sudo apt-get install r-base r-base-dev
By upgrading the repository, r-cran-* will be installed.
$ sudo apt-get upgrade
The following should be displayed.
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be upgraded:
r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools
r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-matrix
r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial
17 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.2MB of archives.
After this operation, 827kB disk space will be freed.
Do you want to continue [Y/n]?
$ sudo R CMD javareconf
$ sudo R
A GUI will popup asking you to select a mirror to download from. Select the same mirror as before, though it doesn’t matter.
After installation is completed. Add the library and install the ggplot2 library.
install.packages('ggplot2', dep = TRUE)
This will take some time.
After that, you can start JGR by typing
This will bring up JGR.
But this is not the end. Please look at the shell carefully, which says,
Starting JGR run script. This can be done from the shell as well, just run
That means that you don’t have to run R first before running JGR.
Now I will make a launcher of JGR.
Right-click of GNOME menu –> “Edit Menu”
That will pop up Main Menu Dialogue.
In this case, I want to put the JGR launcher under Science, so click “New Item”
Then you will see JRG in the menu. Note that I got the made the icon of JGR from the JGR site. I also customized the user interface. The screenshot is the from Lin4Neuro.