1

I'm trying to install the R package "raster", and am getting the same error reported here: Can not install ggplot package in R 2.14.1. I thought the best way of dealing with this would be to upgrade R, but I did the incantations here http://cran.r-project.org/bin/linux/ubuntu/README, but still have R version 2.14.1.

1) Is there something else I can do to upgrade R on my OS (Ubuntu Precise), or do more recent versions of R depend on more recent versions of Ubuntu?

2) If R upgrade is not practical without OS upgrade, how do I install the correct version of the "raster" package for my platform?

Community
  • 1
  • 1
user1521655
  • 486
  • 3
  • 17
  • If you're still at 2.14 then you didn't correctly do the 'incantations' - Re-read them and try again. – Dason Mar 27 '14 at 21:31

2 Answers2

2

Briefly:

  1. It is extremely easy to get current R (ie 3.0.3) onto Ubuntu 12.04 "Precise" -- just read the fine README at the CRAN site

  2. Once you have done so, also install r-base-dev to make sure you build packages.

  3. Then install the "raster" package from source.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
2

Most likely you missed either the first or second step. You need to have the correct key (which is specified in the "Secure Apt" section of the README) and you need to add a line to your /etc/atp/sources.list file. I actually play around with different distros enough that I have the following script to take care of this for me on distros based on Precise.

#!/usr/bin/env bash

## For newest versions of R
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

# I'm sure there is a better way to add this line to
# the end of /etc/apt/sources.list but this works and I'm lazy
sudo sh -c "echo 'deb http://streaming.stat.iastate.edu/CRAN/bin/linux/ubuntu precise/' >> /etc/apt/sources.list"

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

That should get you updated to the newest version of R and from there you should have no problem getting the newest version of ggplot2.

Dason
  • 60,663
  • 9
  • 131
  • 148
  • I should note that I'm at Iowa State so that server makes sense for me. You might want to use a different CRAN server... – Dason Mar 27 '14 at 21:41
  • 1
    Just use `http://cran.rstudio.com` and you get a global mirror near you, irrespective of where you are. (Wikipedia has the details under 'CDN -- Content Delivery Network'.) – Dirk Eddelbuettel Mar 27 '14 at 21:52
  • Definitely didn't do that first line. Was also using a different mirror, but I assume it was the keys that were the problem. – user1521655 Mar 27 '14 at 22:11
  • @DirkEddelbuettel That sounds like a good idea - I'll change that in my script at some point. I should probably find a better way to add that line to the end of the sources.list as well but I never do bash programming and I don't know where I got that from but it seems to work... – Dason Mar 27 '14 at 22:23
  • @user1521655 You don't have to have the key. If it is missing, you merely get a nagging warning. – Dirk Eddelbuettel Mar 27 '14 at 22:26