Description Usage Arguments Value Examples
View source: R/utils_subsets.R
This generic function is primarily useful for functions that accept column names for
subsetting data. The goal is to provide methods for users to supply either an
unquoted column name or a quoted one (character string). It makes use of the
fact that calling substitute()
on a character string has a class
"character", and class "name" otherwise.
1 | get_sub_name(x)
|
x |
The substituted column name. |
The character vector for use with subsetting data.
1 2 3 4 5 6 7 | get_col <- function(data, column) {
name <- substitute(column)
data[, get_sub_name(name)]
}
get_col(mtcars, hp)
get_col(mtcars, "hp")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.