| read_rds | R Documentation |
Read an R .rds file written by write_rds() (or any rds carrying a
metadata_json attribute) back to a data frame with its artoo_meta
restored. A thin wrapper over read_dataset() with format = "rds".
read_rds(path, col_select = NULL, n_max = Inf, encoding = NULL)
path |
Source |
col_select |
Variables to read. Note: an unknown name is a |
n_max |
Maximum records to read. |
encoding |
Source charset of the string columns. Tip: any SAS or IANA spelling listed by |
A <data.frame> carrying artoo_meta when the file recorded
it. An rds holding anything other than a data frame is a
artoo_error_codec; use readRDS() for arbitrary objects.
write_rds() for the inverse; read_dataset() for the generic
dispatcher.
spec <- artoo_spec(
cdisc_adam_datasets, cdisc_adam_variables,
codelists = cdisc_codelists
)
# ---- Example 1: read a dataset written by write_rds() ----
#
# The restored frame carries the same metadata it was written with.
adsl <- apply_spec(cdisc_adsl, spec, "ADSL", conformance = "off")
path <- tempfile(fileext = ".rds")
write_rds(adsl, path)
back <- read_rds(path)
get_meta(back)@dataset$records
# ---- Example 2: a plain rds still reads as a data frame ----
#
# An rds without artoo metadata reads back as an ordinary frame.
bare <- tempfile(fileext = ".rds")
saveRDS(cdisc_dm, bare)
nrow(read_rds(bare))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.