Description Usage Arguments Value Examples
These functions allow you to select variables based on their names. * 'starts_with()': starts with a prefix * 'ends_with()': ends with a prefix * 'contains()': contains a literal string * 'matches()': matches a regular expression * 'num_range()': a numerical range like x01, x02, x03. * 'one_of()': variables in character vector. * 'everything()': all variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | current_vars()
starts_with(match, ignore.case = TRUE, vars = current_vars())
ends_with(match, ignore.case = TRUE, vars = current_vars())
contains(match, ignore.case = TRUE, vars = current_vars())
matches(match, ignore.case = TRUE, vars = current_vars())
num_range(prefix, range, width = NULL, vars = current_vars())
one_of(..., vars = current_vars())
everything(vars = current_vars())
|
match |
A string. |
ignore.case |
If 'TRUE', the default, ignores case when matching names. |
vars |
A character vector of variable names. When called from inside [select()] these are automatically set to the names of the table. |
prefix |
A prefix that starts the numeric range. |
range |
A sequence of integers, like '1:5' |
width |
Optionally, the "width" of the numeric range. For example, a range of 2 gives "01", a range of three "001", etc. |
... |
One or more character vectors. |
An integer vector giving the position of the matched variables.
1 2 3 4 5 6 7 8 9 10 | nms <- names(iris)
vars_select(nms, starts_with("Petal"))
vars_select(nms, ends_with("Width"))
vars_select(nms, contains("etal"))
vars_select(nms, matches(".t."))
vars_select(nms, Petal.Length, Petal.Width)
vars_select(nms, everything())
vars <- c("Petal.Length", "Petal.Width")
vars_select(nms, one_of(vars))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.