Learn R Programming

fifer (version 1.1)

get.cols: Extract column index

Description

Given a vector of strings and another reference vector, get.cols will search the reference vector for matches and return the column indices where each string was located. See examples.

Usage

get.cols(string, names)

Arguments

string
the name of a variable (string)
names
the names of the variables for which you wish to extract the column

Value

an integer corresponding to the column index(indices)

See Also

make.null, r

Examples

Run this code
names = LETTERS[1:10]
get.cols(c("A", "B", "D"), LETTERS[1:10])  ### works
#get.cols(c("A", "B", "Z"), LETTERS[1:10])  ### doesn't work

Run the code above in your browser using DataLab