order_df | R Documentation |
Can use the summary of another column (target_col
), or specify the order manually (factor_order
).
order_df(
df,
target_col,
value_col = NULL,
fun = NULL,
...,
desc = FALSE,
factor_order = NULL
)
df |
The data frame to sort. |
target_col |
The column (character or factor) to convert to ordered factor. |
value_col |
The column to use to sort |
fun |
Function to use to summarize |
... |
Other options passed on to |
desc |
Should |
factor_order |
A character vector of the unique values in |
data frame
set.seed(42)
df <- data.frame(Col1 = rep(letters[1:3], 3),
Col2 = rnorm(9),
Col3 = 1:9,
stringsAsFactors = FALSE)
suppressWarnings(order_df(df, target_col = "Col1", value_col = "Col2", fun = mean))
suppressWarnings(order_df(df, target_col = "Col1", factor_order = c("b", "a", "c")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.