order_cn: Re-order named columns to front or back of 'data.frame'

Description Usage Arguments Value Author(s) See Also Examples

Description

Re-order named columns to front or back of data.frame

Usage

1
2
3

Arguments

x

data.frame

cn

character vector of column names

Value

data.frame with re-ordered columns

Author(s)

Thomas P. Harte

See Also

data.frame, dplyr::everything, http://stackoverflow.com/questions/27865865/in-dplyr-how-to-delete-and-rename-columns-that-dont-exist-manipulate-all-name

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
tab<- read.table(
       con<- textConnection(
           "Name    Age Salary ID
            Dick     38    32k  1
            Tom      21    21k  2
            Harry    56     NA  3"
       ),
       header=TRUE,
       colClasses=c("character","integer","character","integer")
   )
   close(con)
 tab

 tab %>% order_cn_front(c("Salary","Age"))
 tab %>% order_cn_back(c("Salary","Age"))

tharte/tutils documentation built on Feb. 11, 2020, 9:17 a.m.