Description Usage Arguments Details Value Note Author(s) Examples
order_cols
takes in a data frame and reorders the columns specified by ...
. If front
is TRUE
specified columns are placed before unspecified ones, otherwise they are after unspecified columms.
1 | order_cols(df, ..., front = TRUE)
|
df |
a data frame |
... |
unquoted column names in |
front |
a logical value. Should ... be placed before unspecified columns? |
If all columns in df are specified, df is returned with columns in that order.
df
with its columns reordered
See order_cols_q
for a quoted version.
Sven Halvorson (svenedmail@gmail.com)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # 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"),
stringsAsFactors = FALSE)
df
order_cols(df, d, e)
order_cols(df, a, b, front = FALSE)
# Use with pipes
library("dplyr")
df
filter(nchar(e)>5)
order_cols(e,a)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.