df_order_by_col {oaii} | R Documentation |
Sort data.frame by column name
Description
Sort data.frame by column name
Usage
df_order_by_col(df, col, decreasing = FALSE, on_missing_col = "warn")
Arguments
df |
data.frame, input data.frame |
col |
string, column name as sort source |
decreasing |
flag, should the sort order be increasing or decreasing? |
on_missing_col |
string, behavior for missing column(s): "warn" - log warning, "skip" - skip missing column(s), "stop" - throw error |
Value
Modified input data.frame
Examples
df <- data.frame(
a = c("a", "b", "c"),
b = c(1, 3, 2),
c = c(3, 2, 1)
)
df_order_by_col(df, "b", decreasing = TRUE)
df_order_by_col(df, "c")
[Package oaii version 0.5.0 Index]