loadRDS: loads an RDS object, assigns it to an object of the...

View source: R/shorthands.R

loadRDSR Documentation

loads an RDS object, assigns it to an object of the base-filename

Description

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()

Usage

loadRDS(file, refhook = NULL, overwrite = FALSE)

Arguments

file

path to file

refhook

passed to readRDS

overwrite

whether to overwrite an existing object of the same name. defaults to false.

Examples

## Not run: 
loadRDS(file = '~/Models/Spouses.rds') # assigns object contained in file to variable 'Spouses'

## End(Not run)

rubenarslan/formr documentation built on Feb. 6, 2024, 1:18 a.m.