16

I am unable to install ggplot2 in R 3.0.2 on Ubuntu.

When I run

install.packages('ggplot2',dependencies = TRUE)

I get the following error.

 > install.packages('ggplot2',dependencies = TRUE)
Installing package into ‘/home/gowthamn/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
  dependencies ‘plyr’, ‘testthat’ are not available
also installing the dependencies ‘reshape2’, ‘scales’, ‘Hmisc’

trying URL 'http://cran.rstudio.com/src/contrib/reshape2_1.4.1.tar.gz'
Content type 'application/x-gzip' length 34693 bytes (33 Kb)
opened URL
==================================================
downloaded 33 Kb

trying URL 'http://cran.rstudio.com/src/contrib/scales_0.2.4.tar.gz'
Content type 'application/x-gzip' length 40093 bytes (39 Kb)
opened URL
==================================================
downloaded 39 Kb

trying URL 'http://cran.rstudio.com/src/contrib/Hmisc_3.16-0.tar.gz'
Content type 'application/x-gzip' length 629536 bytes (614 Kb)
opened URL
==================================================
downloaded 614 Kb

trying URL 'http://cran.rstudio.com/src/contrib/ggplot2_1.0.1.tar.gz'
Content type 'application/x-gzip' length 2351203 bytes (2.2 Mb)
opened URL
==================================================
downloaded 2.2 Mb

ERROR: dependency ‘plyr’ is not available for package ‘reshape2’
    * removing ‘/home/gowthamn/R/x86_64-pc-linux-gnu-library/3.0/reshape2’
    Warning in install.packages :
      installation of package ‘reshape2’ had non-zero exit status
    ERROR: dependency ‘plyr’ is not available for package ‘scales’
    * removing ‘/home/gowthamn/R/x86_64-pc-linux-gnu-library/3.0/scales’
    Warning in install.packages :
      installation of package ‘scales’ had non-zero exit status
    ERROR: dependencies ‘plyr’, ‘reshape2’, ‘scales’ are not available for package ‘ggplot2’
    * removing ‘/home/gowthamn/R/x86_64-pc-linux-gnu-library/3.0/ggplot2’
    Warning in install.packages :
      installation of package ‘ggplot2’ had non-zero exit status
    ERROR: dependencies ‘ggplot2’, ‘scales’ are not available for package ‘Hmisc’
    * removing ‘/home/gowthamn/R/x86_64-pc-linux-gnu-library/3.0/Hmisc’
    Warning in install.packages :
      installation of package ‘Hmisc’ had non-zero exit status

I also tried

install.packages(c('reshape2','scales'))

Get the error that plyr is not available.

I also upgraded Ubuntu and also reinstalled latest version of R and updated the packages using update.packages(checkBuilt=TRUE). But, nothing worked. What can I do?

tonytonov
  • 25,060
  • 16
  • 82
  • 98
gnjago
  • 3,391
  • 5
  • 19
  • 17
  • 1
    Do you have package `plyr` installed? Also, if it is not a typo in the version of R, you should consider to upgrade R (current version is 3.2.0). –  Jun 04 '15 at 06:43
  • 1
    3.0.2 is fairly outdated. If you really want to use this version, you will have to compile all the dependencies by hand (go to each package archive and download version compatible with 3.0.2). – Roman Luštrik Jun 04 '15 at 07:33
  • Thank you. It worked. For some reason, sudo apt-get install r-base was installing 3.0.2. I updated the source as mentioned here - http://askubuntu.com/questions/218708/installing-latest-version-of-r-base and it worked. – gnjago Jun 05 '15 at 04:16

5 Answers5

14

If you do not need the latest version, you can install the packaged version distributed by Ubuntu by using:

sudo apt-get install r-cran-ggplot2
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
9

I fixed this problem by typing these command:

$ sudo apt-get install r-cran-plyr
$ sudo apt-get install r-cran-reshape2
American curl
  • 1,259
  • 2
  • 18
  • 21
  • 1
    `r-cran-plyr` and `r-cran-reshape2` are both dependencies of `r-cran-ggplot2`, so using `sudo apt-get install r-cran-ggplot2` should resolve all issue (assuming that the newest version is not required). – Tombart Apr 27 '16 at 22:47
4

You should update your R version (r-base) to the latest. Command line like:

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

updated didn't work for me.

ChaosPredictor
  • 3,777
  • 1
  • 36
  • 46
2

apt-get tracks what repos to look for packages in /etc/apt/sources.list. The default set defined in most people's sources.list does not include CRAN mirrors. For Ubuntu users, you can add the following line to /etc/apt/sources.list:

deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu <linux ver>/

I use 'trusty' Ubuntu version and prefer the berkley cran mirror, so my line looks like:

deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu trusty/

If you need to find out your Ubuntu version, try running:

lsb_release -a

Now apt-get can interact with a CRAN mirror for you. Enjoy!

j_houg
  • 651
  • 6
  • 6
1

Download the newest version of r-base (3.2.2) from [http://cran.es.r-project.org/bin/linux/ubuntu/trusty/] use Ubuntu software Centre to open it and install. This would update your already installed version to the latest. Then try installing the ggplot2 packgage again. It worked for me like magic. Good luck with it!!

Idotchere
  • 11
  • 1