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
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.I also had several problems opening an .RDS file, either "error reading from connection" or "unknown input format". I tried with several R versions, with version 3.4.2. the following worked: (I accidentally uninstalled rstudio and installed it again, also installed older R version 3.4.2, I don't know if that changes anything)
Data_Essay_Account <- readRDS("C:/.../newdirectory/Data_Essay_Account.RDS")
command and it worked.Somehow properly downloading it and then moving it did not work, only after I had it in the temp files. Hard deleting packages did not work for me as I tried that initially.
Unlike the top few answers here, my issue was resolved not by doing anything with my installation of RStudio or cleaning local files, but by re-writing the
RDS
file.I could confirm this because the file was stored in the cloud, and reading it from a variety of windows and mac laptops all failed, but similar
RDS
files from the same S3 bucket worked without a problem.When I re-wrote the
RDS
file, the problem went away.Chunxiao Xu and Rando Hinn's solution above worked for me, with a minor tweak.
First, change directories to your personal R package directory, then run: find -iname '*rds' -a -size 0
Delete the directories containing any 0 length files in the above list. Then reopen R (or RStudio) and reinstall the deleted packages.
You should now be able to list the packages again.
Chunxiao Xu's original suggestion above lists ALL of the R package directories. But the exact locations of these directories will vary from installation to installation, and their addresses will have to be edited for your installation.
Larry Hunsicker