Indices of data frame columns identified by name.

columnIndexOf(x, d, regexp = TRUE)

Arguments

x

name(s) of columns to be searched for

d

data frame whose columns shall be searched

regexp

If TRUE, x of character type are interpreted as regular expressions.

Value

indices of requested columns

Examples

# Find indices of 'Petal.Length' and 'Sepal.Length' columns in the # 'iris' data: columnIndexOf(c('Sepal.Length','Petal.Length'),iris)
#> [1] 1 3
# Alternatively, using regular expressions: columnIndexOf(c('.*Length'),iris)
#> [1] 1 3