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
<
If you have one or more incorrectly installed packages (e.g. because you had to force-reboot during installation) you need to re-install this/these package(s). You can find them using this code:
library(purrr)
.libPaths() %>%
set_names() %>%
map(function(lib) {
.packages(all.available = TRUE, lib.loc = lib) %>%
keep(function(pkg) {
f <- system.file('Meta', 'package.rds', package = pkg, lib.loc = lib)
tryCatch({readRDS(f); FALSE}, error = function(e) TRUE)
})
})
This will return a nested list containing the broken packages:
$`/home/yourname/R`
[1] "brokenpkg"
$`/usr/lib64/R/library`
character(0)
$`/usr/share/R/library`
character(0)
You might need to delete the directories 00LOCK-
that R created in the library location while trying to install the packages.