Description Usage Arguments Details Value Examples
Take a list/vector of strings and use the values as column names.
1 |
arg |
the argument that holds a list of values to be used as column names. |
This is used to take the character values of a list or vector and use them as a comma separated list of column names in a dplyr function. The most common usage would be applied yo the values of a single argument, as in the 'select_these2' example, however it can also be used with ... to transform all ... values to column names - see 'select_these3' example.
something that will resolve to a comma separated list of column names when prefixed with '!!!'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
select_these2 <- function(dat, cols){
select(dat, !!!treat_strings_as_cols(cols))
}
select_these2(mtcars, cols = c("cyl", "wt"))
select_these3 <- function(dat, ...){
dots <- list(...)
select(dat, !!!treat_strings_as_cols(dots))
}
select_these3(mtcars, "cyl", "wt")
select_not_these <- function(dat, cols){
select(dat, -c(!!!treat_strings_as_cols(cols)))
}
select_not_these(mtcars, cols = c("cyl", "wt"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.