colorder: Set data table columns to a specified order

View source: R/utils-conv.R

colorderR Documentation

Set data table columns to a specified order

Description

Set data table columns to a specified order

Usage

colorder(df, col_order)

Arguments

df

a data table to be ordered

col_order

a character vector of column names in the desired order.

Details

This function modifies by reference. If a column that is not present is supplied to col_order, it will simply skip over it without error.

Value

a data table

Examples

x <- data.table::data.table(c = c(1,2,3), b = c(1,2,3), a = c(1,2,3))
col_order <- c("a","b","c")
nsqipr:::colorder(x, col_order)
identical(names(x), col_order)


dylanrussellmd/nsqipr documentation built on Oct. 13, 2023, 11:01 a.m.