安装ggplot2时出现错误

3
我正在尝试运行一个关于 ggplot2 的简单代码,但是出现了以下错误:
source("u1.txt")
Error in library(ggplot2) : there is no package called ‘ggplot2’


Error : package ‘foreign’ was built before R 3.0.0: please re-install it
ERROR: lazy loading failed for package ‘maptools’
* removing ‘/home/shivangi/R/i686-pc-linux-gnu-library/3.0/maptools’
* installing *source* package ‘multcomp’ ...
** package ‘multcomp’ successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (multcomp)
ERROR: dependencies ‘plyr’, ‘reshape2’, ‘scales’ are not available for package ‘ggplot2’
* removing ‘/home/shivangi/R/i686-pc-linux-gnu-library/3.0/ggplot2’

The downloaded source packages are in/tmp/RtmpOGWrr4/downloaded_packages’
Warning messages:
1: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘Rcpp’ had non-zero exit status
2: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘plyr’ had non-zero exit status
3: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘testthat’ had non-zero exit status
4: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘reshape2’ had non-zero exit status
5: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘scales’ had non-zero exit status
6: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘Hmisc’ had non-zero exit status
7: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘maptools’ had non-zero exit status
8: In install.packages("ggplot2", dep = TRUE) :
  installation of package ‘ggplot2’ had non-zero exit status
3个回答

1
今晚我在运行ggplot时遇到了同样的错误,基本上你需要尝试安装所有失败的依赖项。对于我来说,首先是"scales",然后是"munsell",最后(实际问题)是"colorspace",因为它自我升级到3.1.1以来没有被更新。在你的情况下,看起来你想首先尝试安装"foreign",然后再次尝试ggplot2。手动加载出现错误的依赖项,直到找到真正的问题。

0

您可以指定install.packages()调用时也安装所有依赖包:

if(!require(ggplot2)) install.packages('dplyr',dependencies = TRUE)

以上代码首先检查是否已加载 ggplot2 包,如果没有,则尝试加载该软件包。如果无法加载软件包,则尝试安装该软件包及其所有依赖项。


0

安装了RTools后,我成功地运行了这个程序:

install.packages("ggplot2", type="source",dependencies = TRUE)

编译了几个程序包...

确保您的 PATH 已经更新,指向 RTools 正确的位置,即包括

c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin

在前面。

我正在使用Rtools32.exe


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