powered by
Sort data.frame by column name
df_order_by_col(df, col, decreasing = FALSE, on_missing_col = "warn")
Modified input data.frame
data.frame, input data.frame
string, column name as sort source
flag, should the sort order be increasing or decreasing?
string, behavior for missing column(s): "warn" - log warning, "skip" - skip missing column(s), "stop" - throw error
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")
Run the code above in your browser using DataLab