| apply_role_overrides | R Documentation |
Used by infer_spec() and by synthesize_file() (where it also applies
to a reviewed spec read from disk, so identifiers named in the call always
win). Names match the internal or the on-disk column name, ignoring case;
patterns are regular expressions (perl, case-insensitive) matched against
the on-disk name. The options cellsynth.id, cellsynth.id_pattern,
cellsynth.text and cellsynth.text_pattern add session-wide defaults,
e.g. options(cellsynth.id_pattern = "^(pat|subj)") once per session.
apply_role_overrides(
spec,
id = NULL,
text = NULL,
roles = NULL,
id_pattern = NULL,
text_pattern = NULL,
warn_unknown = TRUE
)
spec |
A spec data.frame. |
id, text |
Column names to force to |
roles |
Named character vector, |
id_pattern, text_pattern |
Regular expressions on column names. |
warn_unknown |
Warn about names in |
The spec with roles replaced and reason set to "user: ...".
df <- data.frame(PatKey = sprintf("%04d", 1:60), Visit_Note = "seen",
hb = round(seq(110, 160, length.out = 60)))
path <- file.path(tempdir(), "overrides.csv")
utils::write.csv(df, path, row.names = FALSE)
spec <- infer_spec(read_source(path))
spec <- apply_role_overrides(spec, id = "patkey", text_pattern = "note$")
spec[, c("orig_name", "role", "reason")]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.