Skip to contents

Reads a CDISC Dataset-JSON v1.1 file and returns a data frame with metadata preserved as attributes (labels, lengths).

Usage

read_json(file)

Arguments

file

Path to a .json dataset file.

Value

A data frame with attributes:

label

Dataset label.

column labels

Per-column "label" attributes.

dataset_name

Dataset name stored as "dataset_name" attribute.

See also

write_json() for writing, read_xpt() for XPT I/O.

Other io: json_to_xpt(), write_json(), xpt_to_json()

Examples

dm <- data.frame(
  STUDYID = c("STUDY1", "STUDY1"),
  USUBJID = c("SUBJ01", "SUBJ02"),
  AGE = c(65L, 72L),
  stringsAsFactors = FALSE
)
file <- tempfile(fileext = ".json")
write_json(dm, file, dataset = "DM", label = "Demographics")
dm2 <- read_json(file)
dm2
#>   STUDYID USUBJID AGE
#> 1  STUDY1  SUBJ01  65
#> 2  STUDY1  SUBJ02  72
unlink(file)