readRDS(file) in R

These are suggestions I have come across:

  1. Delete your .Rhistory and .RData files in the directory in which you are running R.
  2. Run update.packages()
  3. 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.

  4. 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

Leave a Comment