loadRDS.Rd
saveRDS()
saves an object to a file, so unlike save()
and load()
you can assign the loaded object to a new variable using readRDS()
.
However, sometimes it may be more convenient to assign the object in the RDS file to an object of the same name as the file. This is what loadRDS()
does. It extracts the filename using basename()
and tools::file_path_sans_ext()
loadRDS(file, refhook = NULL, overwrite = FALSE)
file | path to file |
---|---|
refhook | passed to readRDS |
overwrite | whether to overwrite an existing object of the same name. defaults to false. |
if (FALSE) { loadRDS(file = '~/Models/Spouses.rds') # assigns object contained in file to variable 'Spouses' }