# How to Apply the row() Function in R (Example Code)

In this tutorial, I’ll show how to return row indices and labels using the row() function in the R programming language.

## Creation of Example Data

x <- matrix(10:18, nrow = 3) # Construct matrix object in R x # [,1] [,2] [,3] # [1,] 10 13 16 # [2,] 11 14 17 # [3,] 12 15 18 |

x <- matrix(10:18, nrow = 3) # Construct matrix object in R x # [,1] [,2] [,3] # [1,] 10 13 16 # [2,] 11 14 17 # [3,] 12 15 18

## Example: Return Row Indices of Matrix Using row() Function

row(x) # Print row indices # [,1] [,2] [,3] # [1,] 1 1 1 # [2,] 2 2 2 # [3,] 3 3 3 |

row(x) # Print row indices # [,1] [,2] [,3] # [1,] 1 1 1 # [2,] 2 2 2 # [3,] 3 3 3