df_order_by_col: Sort data.frame by column name

View source: R/df.R

df_order_by_colR 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")


oaii documentation built on May 29, 2024, 5:25 a.m.

Related to df_order_by_col in oaii...