select_helpers: Select helpers

Description Usage Arguments Value Examples

Description

These functions allow you to select variables based on their names.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15

Arguments

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.

Value

An integer vector given the position of the matched variables.

Examples

1
2
3
4
5
6
7
8
9
iris <- tbl_df(iris) # so it prints a little nicer
select(iris, starts_with("Petal"))
select(iris, ends_with("Width"))
select(iris, contains("etal"))
select(iris, matches(".t."))
select(iris, Petal.Length, Petal.Width)
select(iris, everything())
vars <- c("Petal.Length", "Petal.Width")
select(iris, one_of(vars))

dplyr documentation built on May 20, 2017, 1:14 a.m.

Search within the dplyr package
Search all R packages, documentation and source code