Error in readRDS(nsInfoFilePath) : error reading from connection
I encountered the same error while using ggplot2, even with very simple data and graph.
I traced the readRDS
function with the following code :
trace(readRDS, quote(print(ls.str())))
which after running the ggplot code returned something like :
Tracing readRDS(metapath) on entry
file : chr "/home/username/R/x86_64-pc-linux-gnu-library/4.1/farver/Meta/package.rds"
refhook : NULL
I reinstalled the farver
package, the error disappeared and I was finally able to plot the graph I wanted.
This package (and the package.rds file) was probably not installed correctly.
I found a similar issue and the tracing command here.
readRDS(file) in R
These are suggestions I have come across:
- Delete your
.Rhistory
and.RData
files in the directory in which you are running R. - Run
update.packages()
Try and detect "bad files" in your library directories. You can do this in R
# List the library paths
# The issue is likely to be in the first directory
paths = .libPaths()
## Try and detect bad files
list.files(paths,
pattern = "^00LOCK*|*\\.rds$|*\\.RDS$",
full.names = TRUE)
## List files of size 0
l = list.files(paths, full.names = TRUE)
l[sapply(l, file.size) == 0]Delete any files/directories highlighted. You could use
file.remove()
if you really wanted to.Delete the directory in which you have stored your downloaded packages.
Only solution 3 worked for me.
Ref:
- R-sig-Debian mailing list
- Option 3 was a combination of answers provided by different people over the last few years, including Chunxiao Xu, Larry Hunsicker and Frank Harrell
Installing Bioconductor packages error -- Error in readRDS(dest) : error reading from connection
I faced the same problem for BioConductor packages. I found a working solution here.
install.packages("devtools")
devtools::install_github("Bioconductor/BiocManager", ref="ghost-binary-repo")
Error installing packages in RStudio: error reading from connection
This certainly is an issue with your connection:the proxies you are using and repositories configured in your RStudio. I was getting the same error when I was connected to US VPN from India.I disconnected VPN and restarted RStudio and it worked like a charm!
Related Topics
Calculate the Derivative of a Data-Function in R
How to Do Str_Extract with Base R
Converting Between Matrix Subscripts and Linear Indices (Like Ind2Sub/Sub2Ind in Matlab)
How to Change the Size of the Strip on Facets in a Ggplot
How Does R Handle Object in Function Call
Find All Sequences with the Same Column Value
Apply a Function to All Variables Starting with Specific Pattern in R
Removing Attributes of Columns in Data.Frames on Multilevel Lists in R
Changing the Appearance of Facet Labels Size
R Data.Table Join: SQL "Select *" Alike Syntax in Joined Tables
Combine Rows and Sum Their Values
Labelling the Plots with Images on Graph in Ggplot2
Scientific Notation Issue in R
How to Use Gsub() on Each Element of a Data Frame
R: Find Missing Columns, Add to Data Frame If Missing
How to Get Covariance Matrix for Random Effects (Blups/Conditional Modes) from Lme4
Combining Vector and Bitmap Graphics in a PDF
Scatterplot: Error in Fun(X[[I]], ...):Object 'Group' Not Found