orderCol: orderCol()

Description Usage Arguments Examples

View source: R/helper_functions.R

Description

reorder df by specified columns

Usage

1
orderCol(df, cols, decreasing = F)

Arguments

df

input df

cols

column names in strings (add - if want to sort by descending order()only for numeric ), use decreasing =T for other type

Examples

1
2
3
4
5
6
df <- data.frame(col1 = c('a', 'a', 'b','b'),
                 col2 = c('orange', 'red', 'red', 'grey'),
                 col3 = c(3,6,8,5))
cols = c('col1', 'col2')
orderCol(df, cols)
orderCol(df, '-col3')

BerylZhuang/helper_functions documentation built on March 15, 2021, 5:19 a.m.