| get_meta | R Documentation |
Pull the artoo_meta off a data frame produced by apply_spec() or read
back by any read_*() codec. The metadata travels as a single
Dataset-JSON string in the frame's metadata_json attribute; get_meta()
parses it to the S7 object, the form every codec writes from. This is the
read half of the lossless round-trip.
get_meta(x)
x |
A data frame carrying artoo metadata. Requirement: |
A <artoo_meta> with two properties. @dataset is a named
list of dataset-level attributes: itemGroupOID, name, label,
records, studyOID, metaDataVersionOID, encoding, and keys.
@columns is a named list with one entry per variable, each carrying
itemOID, name, label, dataType, targetDataType, length,
displayFormat, informat, keySequence, codelist,
significantDigits, and origin (absent values are NULL). Pass it
to set_meta() to re-attach, or index it directly
(meta@columns$AGE$label).
set_meta() for the write half; apply_spec() which stamps it.
# ---- Example 1: read metadata off a conformed dataset ----
#
# apply_spec() stamps the metadata; get_meta() reads it back as the S7
# object whose @columns holds one CDISC attribute set per variable.
spec <- artoo_spec(cdisc_adam_datasets, cdisc_adam_variables, codelists = cdisc_codelists)
adsl <- apply_spec(cdisc_adsl, spec, "ADSL")
meta <- get_meta(adsl)
meta@columns$STUDYID
# ---- Example 2: round-trip metadata across two frames ----
#
# The metadata is a portable object: read it off one frame and stamp it
# onto another with set_meta().
bare <- as.data.frame(adsl)
attr(bare, "metadata_json") <- NULL
restamped <- set_meta(bare, meta)
identical(get_meta(restamped)@columns, meta@columns)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.