简体   繁体   中英

`saveRDS` cannot save a .RData to a location outside of the working directory

I can't add any file path such as ../folder/smaller-folder/stuff.RData or ./folder/smaller folder/stuff.RData or folder/smaller folder/stuff.RDS . Any version of the file path returns the same error

Warning in gzfile(file, mode) :
  cannot open compressed file 'folder/smaller-folder/stuff.RData', probable reason 'No such file or directory'
Error in gzfile(file, mode) : cannot open the connection

A sample code from https://rstudio-education.github.io/hopr/dataio.html

saveRDS(a, file = "stuff.RDS") 
a <- readRDS("stuff.RDS")

What did I miss? Any leads is much appreciated.

Turned out I need ~ in saveRDS(a, file = "~/folder/smaller-folder/stuff.RDS") . Folder names have both upper and lower cases. Thank you all so much for all the hints.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM