read_RDS_or_RDA | R Documentation |
This is like readRDS()
except that it can also read from an RData
file containing a single object (i.e. the kind of file that is read
using load()
). Use this in place of readRDS()
if you want to be
slightly more forgiving about what kind of R data file you accept.
read_RDS_or_RDA(filename, expected.class = "ANY")
filename |
The file to read an R object from. |
expected.class |
If specified, the object will be coerced into
this class using |
The object read from the file, possibly after coercing it into another class.
readRDS()
, read_single_object_from_rda()
, as()
tmpf <- tempfile() saveRDS(1:10, tmpf) read_RDS_or_RDA(tmpf) read_RDS_or_RDA(tmpf, "character") # Using a function instead of a class name. read_RDS_or_RDA(tmpf, as.character) read_RDS_or_RDA(tmpf, "factor") read_RDS_or_RDA(tmpf, "data.frame") ## Not run: # This will throw an error because the coercion to "lm" is not # possible. read_RDS_or_RDA(tmpf, "lm") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.