Description Usage Arguments Details Value Author(s) See Also Examples
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.
1 | order_cols_q(df, first = NA, last = NA)
|
df |
a data frame |
first, last |
character vectors or NA |
All ellements of first
and last
must be in the column names of df and not be NA
. first
and last
may not overlap.
df
with its columns reordered
Sven Halvorson (svenedmail@gmail.com)
order_cols
now uses nonstandard evaluation.
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"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.