View source: R/roles_actions.R
| set_role | R Documentation |
Ergonomic editor for the two-axis roles table returned by
propose_roles(). Setting a role without an explicit action
re-resolves the action to the default for the new role, the column's
kind, and the mode the table was proposed for – so a re-roled column
never silently carries a stale action from its previous role.
set_role(roles, cols, role = NULL, action = NULL)
roles |
A roles table from |
cols |
Character vector of column names to edit. Every entry
must be present in |
role |
Optional single role to assign to all of |
action |
Optional single action to assign to all of |
Direct edits (roles$role[roles$col == "x"] <- "outcome") also work,
but leave roles$action unchanged.
The edited roles table.
propose_roles(), roles_validate().
r <- propose_roles(iris)
r <- set_role(r, "Sepal.Length", role = "outcome")
r <- set_role(r, "Species", action = "keep")
r[, c("col", "role", "action")]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.