Whenever I try to install a package in R, I get the following error:
Error in readRDS(file) : unknown input format
This just started occurring after I had a system crash. I am running 32 bit R 2.13.0 under windows 7. I tried removing and re-installing R, but continue to get the error. Is there any way I can fix this without deleting everything (i.e. all the packages I've installed) and starting over?
Thanks
R has its own data file format–it's usually saved using the . rds extension. To read a R data file, invoke the readRDS() function. As with a CSV file, you can load a RDS file straight from a website, however, you must first run the file through a decompressor before attempting to load it via readRDS .
Rds files store a single R object. According to R documentation: These functions provide the means to save a single R object to a connection (typically a file) and to restore the object, quite possibly under a different name.
If you cannot open your RDS file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a RDS file directly in the browser: Just drag the file onto this browser window and drop it.
The RData format (usually with extension . rdata or . rda) is a format designed for use with R, a system for statistical computation and related graphics, for storing a complete R workspace or selected "objects" from a workspace in a form that can be loaded back by R.
These are suggestions I have come across:
.Rhistory
and .RData
files in the directory in which you are running R.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:
Run find /usr/local/lib/R/site-library/ /usr/lib/R/library/ /usr/lib/R/site-library/ ~/.local/lib/ -iname '*rds' -a -size 0
and then delete the files found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With