co_relevels | R Documentation |
Reorder Two Columns Levels Simultaneously
co_relevels(df, primary, secondary, levels_primary)
df |
( |
primary |
( |
secondary |
( |
levels_primary |
( |
The function expect a 1:1 matching between the elements of the two selected column.
a data.frame
with the secondary
column converted to factor with reordered levels.
df <- data.frame(
SUBJID = 1:3,
PARAMCD = factor(c("A", "B", "C")),
PARAM = factor(paste("letter", LETTERS[1:3]))
)
co_relevels(df, "PARAMCD", "PARAM", levels_primary = c("C", "A", "B"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.