| read_json | R Documentation |
Read a CDISC Dataset-JSON v1.1 (.json) file back to a data frame,
restoring the full artoo_meta it carries and realizing SAS
date/datetime/time variables to R Date / POSIXct / hms::hms. Column
types are reconstructed from the recorded metadata, not guessed from the
JSON tokens, so the round-trip is lossless. The ingest end of the I/O layer;
a thin wrapper over read_dataset() with format = "json".
read_json(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 file bytes. Tip: any SAS or IANA spelling listed by |
A <data.frame> carrying artoo_meta (read it with
get_meta()).
write_json() for the inverse; read_dataset() for the generic
dispatcher.
spec <- artoo_spec(cdisc_adam_datasets, cdisc_adam_variables, codelists = cdisc_codelists)
# ---- Example 1: round-trip a conformed dataset through Dataset-JSON ----
#
# The variable labels, types, and keys survive the round-trip.
adsl <- apply_spec(cdisc_adsl, spec, "ADSL", conformance = "off")
path <- tempfile(fileext = ".json")
write_json(adsl, path)
back <- read_json(path)
identical(get_meta(back)@columns, get_meta(adsl)@columns)
# ---- Example 2: the metadata names the dataset and row count ----
#
# The restored artoo_meta exposes the dataset-level attributes.
get_meta(back)@dataset$records
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.