ggplot2无法在R 3.0.2上安装

16

我无法在Ubuntu上安装R 3.0.2中的ggplot2。

当我运行以下命令时:

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

我遇到了以下错误。

 > 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

我也尝试过

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

出现“plyr不可用”的错误。

我还升级了Ubuntu,重新安装了最新版本的R,并使用update.packages(checkBuilt=TRUE)更新了软件包。但是,什么都没有起作用。我该怎么办?


1
你安装了 plyr 包吗?另外,如果 R 版本号没有打错的话,建议你考虑升级 R(当前版本为3.2.0)。 - user3710546
1
3.0.2版本已经相当过时了。如果你真的想使用这个版本,你必须手动编译所有依赖项(前往每个软件包存档并下载与3.0.2兼容的版本)。 - Roman Luštrik
谢谢。它起作用了。由于某些原因,sudo apt-get install r-base 安装的是 3.0.2 版本。我按照这里提到的步骤更新了源 - http://askubuntu.com/questions/218708/installing-latest-version-of-r-base,现在它可以正常工作了。 - gnjago
5个回答

14

如果您不需要最新版本,可以使用以下方法安装由Ubuntu分发的打包版本:

sudo apt-get install r-cran-ggplot2

9

我通过输入以下命令来解决了这个问题:

$ sudo apt-get install r-cran-plyr
$ sudo apt-get install r-cran-reshape2

1
r-cran-plyrr-cran-reshape2都是r-cran-ggplot2的依赖项,因此使用sudo apt-get install r-cran-ggplot2应该解决所有问题(假设不需要最新版本)。 - Tombart

4
你需要更新你的R版本(r-base)到最新版。 命令行如下:
$ sudo apt-get update
$ sudo apt-get install r-base

更新对我没有用。


2

apt-get会跟踪/etc/apt/sources.list中指定的软件包仓库。大多数人的sources.list文件中默认设置不包括CRAN镜像。对于Ubuntu用户,您可以将以下行添加到/etc/apt/sources.list文件中:

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

我使用“trusty”版本的Ubuntu,并且更喜欢伯克利的Cran镜像,因此我的命令行如下:
deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu trusty/

如果您需要查找Ubuntu版本,请尝试运行以下命令:lsb_release -a
lsb_release -a

现在apt-get可以与CRAN镜像进行交互。尽情享受吧!

1

从 [http://cran.es.r-project.org/bin/linux/ubuntu/trusty/] 下载最新版本的r-base(3.2.2),使用Ubuntu软件中心打开并安装。这样可以将您已安装的版本更新到最新版本,然后再尝试安装ggplot2包。这对我来说就像魔法一样有效。祝您好运!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接