从 3.3.1(全 64 位)安装 R 3.4.0 后,我在 Windows 10 上遇到此错误。通过从 CRAN 手动安装一个不相关的包解决了这个问题(我使用了 ggplot2)。不知道根本原因是什么,但也许这也对你有用。
我的代码输出:
> library(pacman)
> p_load(plyr, XLConnect, ggplot2, stringr, magrittr, kirkegaard, lubridate, weights, psych, psychometric, polycor, effsize, readr)
Installing package into ‘C:/Users/Emil/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Error in install.packages : error reading from connection
Error in loadNamespace(name) : there is no package called ‘BiocInstaller’
然后我重新启动 R,并运行相同的代码:
> library(pacman)
> p_load(plyr, XLConnect, ggplot2, stringr, magrittr, kirkegaard, lubridate, weights, psych, psychometric, polycor, effsize, readr)
Installing package into ‘C:/Users/Emil/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Error in readRDS(dest) : error reading from connection
即相同的代码,不同的错误。奇怪的。然后我再次重新启动 R 并安装了一个随机包,然后重新运行我的代码并且它工作了。
> install.packages("ggplot2")
Warning in install.packages :
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES.rds': HTTP status was '404 Not Found'
Installing package into ‘C:/Users/Emil/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/ggplot2_2.2.1.zip'
Content type 'application/zip' length 2782171 bytes (2.7 MB)
downloaded 2.7 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Emil\AppData\Local\Temp\RtmpCq4cFX\downloaded_packages
> library(pacman)
> p_load(plyr, XLConnect, ggplot2, stringr, magrittr, kirkegaard, lubridate, weights, psych, psychometric, polycor, effsize, readr)
Installing package into ‘C:/Users/Emil/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/effsize_0.7.1.zip'
Content type 'application/zip' length 36713 bytes (35 KB)
downloaded 35 KB
package ‘effsize’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Emil\AppData\Local\Temp\RtmpCq4cFX\downloaded_packages
effsize installed
因此,错误似乎与 pacman 尝试安装 effsize 有关。