无法在R中安装tidyverse包。出现错误,提示没有名为的包。

6
我正在尝试在R Studio中安装包tidy verse,但出现了以下错误。
> install.packages('tidyverse')
also installing the dependency ‘rstudioapi’

  There is a binary version available but the source version is later:
           binary source needs_compilation
rstudioapi  0.9.0   0.10             FALSE

trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/tidyverse_1.2.1.tgz'
Content type 'application/x-gzip' length 88754 bytes (86 KB)
==================================================
downloaded 86 KB


The downloaded binary packages are in
    /var/folders/kn/b21xc36111z157czpz0swc900000gn/T//RtmpeVGvVh/downloaded_packages
installing the source package ‘rstudioapi’

trying URL 'https://cran.rstudio.com/src/contrib/rstudioapi_0.10.tar.gz'
Content type 'application/x-gzip' length 61888 bytes (60 KB)
==================================================
downloaded 60 KB

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called ‘assertthat’
Calls: time.to ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
Warning in install.packages :
  installation of package ‘rstudioapi’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/kn/b21xc36111z157czpz0swc900000gn/T/RtmpeVGvVh/downloaded_packages’

此外,我尝试在基本的R中安装,收到了相同的消息。我已经进入临时文件夹并解压缩了该包,并将其移动到库文件夹。当我尝试使用 library(assertthat) 时,它会给我一个错误,说没有安装有效的包。

在这台机器上,我以前成功地安装了 tidyverse,但这次尝试使用它时,它告诉我未安装,所以我尝试重新安装它。


1
正如错误所述,assertthat包未安装,因此您需要先安装它。 - dipetkov
我尝试过了,但是出现了相同的错误:没有叫做 'assertthat' 的包。 - CT Hall
3
请尝试重新启动全新的R语言会话,运行install.packages('assertthat'),然后运行library(assertthat)。如果一切顺利,请重新启动并尝试安装tidyverse。 - Tyler Rinker
1
@TylerRinker 在我删除了 .Rhistory、.Rdata 和 .Rprofile 文件之后,尝试重新安装似乎起作用了。谢谢。 - CT Hall
1
很好,把它作为答案放下,让其他未来遇到类似问题的人可以参考。 - Tyler Rinker
2个回答

6

我删除了我的 .Rhistory、.Rdata 和 .Rprofile 文件,重新启动了 R,并能够无问题地安装 tidyverse


3
我简直不敢相信它这么简单。我挣扎了30分钟,但然后跟着这个方法,就解决了。 - Vaibhav Singh

1

我重新启动了电脑,并使用install.packages("devtools")安装了devtools。

之后,我确保将Rtools添加到PATH中,只需按照这里的说明操作:在Windows上使用Rtools40

然后,我就能够使用install.packages("tidyverse")安装tidyverse了。


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