match Function in R (Example)
This page illustrates how to apply the match function in the R programming language.
Example Data
We use the following numeric vector as example data:
x <- c(3, 3, 3, 1, 3, 2, 5, 7) # Create example vector |
x <- c(3, 3, 3, 1, 3, 2, 5, 7) # Create example vector
Example: Application of match Function
We can identify the position of the value 1 within our example vector as follows:
match(1, x) # Apply match function # 4 |
match(1, x) # Apply match function # 4