Installing R Packages Error in readRDS(file) : error reading from connection

后端 未结 9 1528
鱼传尺愫
鱼传尺愫 2021-01-03 19:48

Whenever I try to install any package in R on Ubuntu 14.04, I\'m getting the following error:

Error in readRDS(file) : error reading from connection
<         


        
9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 20:15

    I had this error on Windows 10 after installing R 3.4.0 from 3.3.1 (all 64-bit). It was resolved by manually installing an unrelated package from CRAN (I used ggplot2). No idea what the root cause was, but perhaps this will work for you as well.

    Output from my code:

    > 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’ 
    

    Then I restarted R, and ran the same code:

    > 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
    

    I.e. same code, different error. Odd. Then I restarted R again and installed a random package, then reran my code and it worked.

    > 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
    

    So, error seems to have had something to do with pacman trying to install effsize.

提交回复
热议问题