简体   繁体   English

安装ggp​​lot2时出错

[英]Error installing ggplot2

I was trying to run a simple code on ggplot2 and got the following error:我试图在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

I had the same error running ggplot this evening, essentially you need to try to install all the dependencies that failed.今晚我在运行 ggplot 时遇到了同样的错误,基本上你需要尝试安装所有失败的依赖项。 For me it was "scales", then "munsell" and then finally (the actual problem) "colorspace" which hadn't be updated since I upgraded to 3.1.1.对我来说,它是“scales”,然后是“munsell”,最后是(实际问题)“colorspace”,自从我升级到 3.1.1 以来就没有更新过。 In your case, it looks like you want to first try installing "foreign" and then try ggplot2 again.在您的情况下,您似乎想先尝试安装“foreign”,然后再尝试 ggplot2。 Keep loading dependencies that error manually until you find the real problem.继续手动加载错误的依赖项,直到找到真正的问题。

You can specify that the install.packages() call also install all dependent packages:您可以指定install.packages()调用也安装所有依赖包:

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

the above code first checks to see if ggplot2 package is loaded, if not it tries to load the apckage.上面的代码首先检查是否加载了 ggplot2 包,如果没有,它会尝试加载 apckage。 If it cannot load the package, it then tries to install the package and all of package its dependencies.如果它无法加载包,则它会尝试安装该包及其所有依赖项。

With RTools installed, I got this to work:安装了 RTools 后,我开始工作了:

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

Compiled a few packages...编译了几个包...

Make sure your PATH is updated to point to RTools properly, ie includes确保您的 PATH 已更新以正确指向 RTools,即包括

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

at the front.在前面。

I am using Rtools32.exe我正在使用 Rtools32.exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM