ordfactby | R Documentation |
Converts a column into an ordered factor.
ordfactby(data, column, by, ...)
data |
a data frame or tibble |
column |
the column to convert to an ordered factor |
by |
the column used to order |
... |
expressions passed to |
column
, by
, and ...
use tidyselect (e.g. column names do not need to be quoted)
The dataframe with column
converted to an ordered factor that is ordered according to by
library(tidyr) mtcars$Model <- rownames(mtcars) ordfactby(mtcars, Model, gear) #turns column Model into an ordered factor ordered by gear
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.