Learn R Programming

maSigPro (version 1.44.0)

position: Column position of a variable in a data frame

Description

Finds the column position of a character variable in the column names of a data frame.

Usage

position(matrix, vari)

Arguments

matrix
matrix or data.frame with character column names
vari
character variable

Value

numerical. Column position for the given variable.

Examples

Run this code
x <- matrix(c(1, 1, 2, 2, 3, 3),ncol = 3,nrow = 2)
colnames(x) <- c("one", "two", "three")
position(x, "one") 

Run the code above in your browser using DataLab