section_datasets.RdProduces the dataset-inventory table expected in a Reviewer's Guide: one row per dataset with its label, class/structure, key variables, record and variable counts, and in-memory size.
section_datasets(datasets, metadata = NULL)Either a named list of data frames (the name is used as the
dataset name), or an already-assembled metadata data frame, which is
returned as a tibble unchanged (metadata is then ignored).
Optional study metadata carrying the declared key
variables. Either a data frame with columns dataset, variable and
key_seq (names are matched case- and separator-insensitively, so
"Key Seq" and key_seq are the same column), or any object exposing
such a table as $ds_vars — which is the shape of a metacore object,
so metacore::define_to_metacore(...) output can be passed straight in.
Rows with key_seq = NA are ignored; keys are ordered by key_seq and
dataset names are matched case-insensitively.
A tibble with columns dataset, label, class, key_variables,
key_source, records, variables, size.
Key variables are either declared or guessed, and the
key_source column always says which:
"declared" — the variables came from metadata, in key_seq order.
These are reproduced as declared, including any key variable that is not
present in the data frame (that mismatch is itself worth reviewing).
"heuristic" — no metadata was supplied for that dataset, so the keys
are a name-pattern guess: the usual identifier names (STUDYID,
USUBJID, DOMAIN, SUBJID, PARAMCD, VISITNUM, VISIT, AVISIT)
plus any variable ending in SEQ or ID, falling back to the first two
variables. It is not a keying analysis: it can miss a real key and can
invent one. Supply metadata whenever the study has it.
adsl <- read.csv(system.file("extdata", "adsl.csv", package = "reviewerguider"))
adae <- read.csv(system.file("extdata", "adae.csv", package = "reviewerguider"))
# No metadata: keys are guessed from variable names.
section_datasets(list(adsl = adsl, adae = adae))
#> # A tibble: 2 × 8
#> dataset label class key_variables key_source records variables size
#> <chr> <chr> <chr> <chr> <chr> <int> <int> <chr>
#> 1 adsl NA data.frame STUDYID, USUBJID,… heuristic 6 7 2.7 …
#> 2 adae NA data.frame STUDYID, USUBJID,… heuristic 6 5 2.4 …
# With declared keys (here, the real CDISCPILOT01 ADaM define.xml keys).
keys <- read.csv(system.file("extdata", "dataset_keys.csv", package = "reviewerguider"))
section_datasets(list(adsl = adsl, adae = adae), metadata = keys)
#> # A tibble: 2 × 8
#> dataset label class key_variables key_source records variables size
#> <chr> <chr> <chr> <chr> <chr> <int> <int> <chr>
#> 1 adsl NA data.frame USUBJID declared 6 7 2.7 …
#> 2 adae NA data.frame USUBJID, AETERM, … declared 6 5 2.4 …