R 无法将ggplot 2下载为';lib';未明

R 无法将ggplot 2下载为';lib';未明,r,ggplot2,rstudio,install.packages,R,Ggplot2,Rstudio,Install.packages,我在过去安装和运行ggplot2没有问题,但是突然R studio再也找不到ggplot2包了。我尝试重新安装软件包,但尽管控制台运行了代码并“下载”了软件包,但库(ggplot2)给了我一个错误: Error in library(ggplot2) : there is no package called ‘ggplot2’ 我已经试过了: install.packages("ggplot2", repos = c("http://rstudio.org/_pack

我在过去安装和运行ggplot2没有问题,但是突然R studio再也找不到ggplot2包了。我尝试重新安装软件包,但尽管控制台运行了代码并“下载”了软件包,但库(ggplot2)给了我一个错误:

Error in library(ggplot2) : there is no package called ‘ggplot2’
我已经试过了:

install.packages("ggplot2",
             repos = c("http://rstudio.org/_packages",
                       "http://cran.rstudio.com"))
我还尝试:

install.packages("ggplot2", dependencies = TRUE)
我还卸载并重新安装了Rstudio,以管理员身份运行,但没有任何效果

这是控制台在运行命令时显示的内容

install.packages("ggplot2")
控制台输出如下所示:

Installing package into ‘C:/Users/Keith/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
also installing the dependency ‘rlang’


  There are binary versions available but the source versions are later:
        binary source needs_compilation
rlang    0.2.0  0.3.1              TRUE
ggplot2  2.2.1  3.1.0             FALSE

  Binaries will be installed
trying URL 
'https://cran.rstudio.com/bin/windows/contrib/3.3/rlang_0.2.0.zip'
Content type 'application/zip' length 754726 bytes (737 KB)
downloaded 737 KB

package ‘rlang’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\Keith\AppData\Local\Temp\RtmpmKus85\downloaded_packages
installing the source package ‘ggplot2’

trying URL 'https://cran.rstudio.com/src/contrib/ggplot2_3.1.0.tar.gz'
Content type 'application/x-gzip' length 2863109 bytes (2.7 MB)
downloaded 2.7 MB

* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck 
= vI[[j]]) : 
  namespace 'rlang' 0.2.0 is being loaded, but >= 0.2.1 is required
ERROR: lazy loading failed for package 'ggplot2'
* removing 'C:/Users/Keith/Documents/R/win-library/3.3/ggplot2'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l 
 "C:\Users\Keith\Documents\R\win-library\3.3"
C:\User\Keith\AppData\Local\Temp\RtmpmKus85/downlaoaded_packages/ggplot2_3.1.0.tar.gz' had status 1
Warning in installed.packages:
installation of package 'ggplot2' had non-zero exit status
将软件包安装到'C:/Users/Keith/Documents/R/win library/3.3'中
(由于“lib”未指定)
同时安装依赖项“rlang”
有二进制版本可用,但源版本更高:
二进制源代码需要编译
rlang 0.2.0 0.3.1正确
ggplot2.2.1 3.1.0错误
将安装二进制文件
正在尝试的URL
'https://cran.rstudio.com/bin/windows/contrib/3.3/rlang_0.2.0.zip'
内容类型“application/zip”长度754726字节(737KB)
下载737KB
包“rlang”已成功解包并检查MD5总和
下载的二进制软件包位于
C:\Users\Keith\AppData\Local\Temp\RtmpmKus85\downloaded\u程序包
正在安装源程序包“ggplot2”
正在尝试URL'https://cran.rstudio.com/src/contrib/ggplot2_3.1.0.tar.gz'
内容类型“应用程序/x-gzip”长度2863109字节(2.7 MB)
下载2.7 MB
*正在安装*源*包“ggplot2”。。。
**包“ggplot2”已成功解包并检查MD5总和
**R
**资料
***将数据集移动到lazyload DB
**仪表
**为延迟加载准备包
loadNamespace中出错(需要j=0.2.1
错误:包“ggplot2”的延迟加载失败
*删除“C:/Users/Keith/Documents/R/win library/3.3/ggplot2”
install.packages中的警告:
正在运行命令“C:/PROGRA~1/R/R-33~1.1/bin/x64/R”CMD INSTALL-l
“C:\Users\Keith\Documents\R\win library\3.3”
C:\User\Keith\AppData\Local\Temp\RtmpmKus85/downloaaded_packages/ggplot2_3.1.0.tar.gz“状态为1”
已安装软件包中的警告:
包“ggplot2”的安装具有非零退出状态

安装
rlang
然后再试一次?看起来您使用的是相当旧的R版本,能否更新到
3.5.2
?我使用的R studio版本是1.1.463,这是R studio网站上的最新更新,因为我卸载了它并重新下载了整个版本program@KeithAu董是指你的R版本(3.3基于您发布的内容),而不是R Studio版本。您可以找到R的最新版本