order_cols_q: Re-order columns of a data frame (quoted)

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/order_cols_q.R

Description

order_cols_q takes in a data frame and places the columns specified by first at the front and those by last at the end. If one of first or last are left as NA, they will be ignored.

Usage

1
order_cols_q(df, first = NA, last = NA)

Arguments

df

a data frame

first, last

character vectors or NA

Details

All ellements of first and last must be in the column names of df and not be NA. first and last may not overlap.

Value

df with its columns reordered

Author(s)

Sven Halvorson ([email protected])

See Also

order_cols now uses nonstandard evaluation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# We'll demonstrate reorder here
library("dplyr")
df = data.frame(a = 1:4,
                b = letters[4:7],
                c = rnorm(n = 4),
                d = rchisq(n = 4, df = 3),
                e = c("Salty", "Sweet", "Subtle", "Sweaty"))
order_cols(df, first = "d", last = c("a","e"))

order_cols(df, last = c("c", "a"))


df 
  filter(a <3) 
  order_cols(c("c","d"))

svenhalvorson/SvenR documentation built on June 24, 2018, 9:25 a.m.