Learn R Programming

useful (version 1.2.6)

colsToFront: colsToFront

Description

Moves column names to the front or back of the names

Usage

colsToFront(data, cols = names(data))

colsToBack(data, cols = names(data))

Value

Character vector of column names

Arguments

data

data.frame or tbl

cols

Columns that should be moved

Author

Jared P. Lander

Details

Moves column names to the front or back of the names

Examples

Run this code
theDF <- data.frame(A=1:10, B=11:20, C=1:10, D=11:20)
colsToFront(theDF, c('B', 'C'))
colsToFront(theDF, c('C', 'B'))
colsToFront(theDF, c('C', 'C'))
colsToBack(theDF, c('C', 'C'))
colsToBack(theDF, c('C', 'B'))
colsToBack(theDF, c('C', 'C'))

Run the code above in your browser using DataLab