| write_dataset | R Documentation |
Serialize a data frame to a clinical file format, preserving its
artoo_meta losslessly. The codec is chosen from the file extension (or an
explicit format), so one call covers xpt, Dataset-JSON, Parquet, and rds.
This is the emit end of the artoo workflow; the per-format wrappers like
write_rds() are thin sugar over it.
write_dataset(x, path, format = NULL, ...)
x |
The dataset to write. |
path |
Destination file path. |
format |
Force a codec instead of inferring from the extension.
|
... |
Codec-specific arguments passed through to the encoder (see
the per-format wrappers, e.g. |
The input x, invisibly, so a write can sit mid-pipeline.
Called for the side effect of writing path.
read_dataset() for the inverse; write_rds() for the
per-format wrapper; artoo_formats() for what is available.
spec <- artoo_spec(cdisc_adam_datasets, cdisc_adam_variables, codelists = cdisc_codelists)
# ---- Example 1: write a conformed dataset, inferring rds from the path ----
#
# apply_spec() attaches the metadata; write_dataset() carries it into the
# file so a later read is lossless.
adsl <- apply_spec(cdisc_adsl, spec, "ADSL", conformance = "off")
path <- tempfile(fileext = ".rds")
write_dataset(adsl, path)
# ---- Example 2: force the format for an unconventional extension ----
#
# When the extension does not name the format, pass it explicitly.
alt <- tempfile(fileext = ".data")
write_dataset(adsl, alt, format = "rds")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.