| map_data | R Documentation |
Utility to map variables in a data.frame to specific roles, with options to trim variables not assigned to roles, to rename variables to match variable roles (vs. attaching a variable map as an attribute), and to clear the console with each step in variable mapping.
map_data(
x,
roles,
defs,
opt.roles = NULL,
opt.defs = NULL,
trim = TRUE,
rename = TRUE,
clear = TRUE
)
x |
A rectangular atomic data.frame whose variables are to be mapped. |
roles |
Unique string multivec containing labels for required variable roles (that are also valid object names without back-quoting). |
defs |
Unique string multivec with |
opt.roles |
Optional unique string multivec containing labels for optional variable roles (that are also valid object names without back-quoting). |
opt.defs |
Optional unique string multivec with |
trim, rename, clear |
Logical scalar indicating, respectively, whether to trim un-mapped variables from |
Variable mapping is conducted interactively via the console for all variable roles in roles and opt.roles that do not have matching variable names in x. For variable roles in roles and opt.roles that have matching variable names in x, matching is done automatically.
A rectangular atomic data.frame.
dg <- 1:9
ai <- letters[dg]
AI <- LETTERS[dg]
uf <- factor(ai)
of <- ordered(AI)
tf <- ai %in% c("a", "e", "i", "o", "u")
dtf <- data.frame(dg = dg, ai = ai, AI = AI, uf = uf, of = of, tf = tf, stringsAsFactors = F)
roles <- c("dg", "ai", "AI")
ROLES <- c("uf", "of", "tf")
defs <- c("digits 1 through 9", "lowercase a-i" , "uppercase A-I" )
DEFS <- c("unordered factor" , "ordered factor", "sampled logical values")
map_data(dtf, roles, defs)
map_data(dtf, roles, defs, trim = F)
map_data(dtf, roles, defs, opt.roles = ROLES, opt.defs = DEFS)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.