spec_keys: Sort keys for a dataset

View source: R/spec_accessors.R

spec_keysR Documentation

Sort keys for a dataset

Description

Parse a dataset's sort keys into a character vector of variable names. These keys drive the sort step of apply_spec() and the keySequence written to each output format.

Usage

spec_keys(spec, dataset)

Arguments

spec

The specification to read. ⁠<artoo_spec>: required⁠.

dataset

The dataset whose keys to parse. ⁠<character(1)>: required⁠.

Restriction: must name a dataset in the spec.

Value

A character vector of key variable names, split from the dataset's keys cell (whitespace- or comma-separated). Empty when no keys are declared.

See Also

spec_datasets() for the dataset names; spec_variables() for the variables a key must reference.

Examples

# ---- Example 1: parse a dataset's sort keys ----
#
# Declare DM's keys, then read them back as the ordered vector apply_spec()
# sorts by. (STUDYID and USUBJID are real DM variables in the demo data.)
ds <- cdisc_sdtm_datasets
ds$keys[ds$dataset == "DM"] <- "STUDYID USUBJID"
spec <- artoo_spec(ds, cdisc_sdtm_variables, codelists = cdisc_codelists)
spec_keys(spec, "DM")


artoo documentation built on July 23, 2026, 1:08 a.m.