** row()** function in R Language is used to get the row number of a matrix.

Syntax:row(x, as.factor=FALSE)

Parameters:

x:matrix

as.factor:a logical value indicating whether the value should be returned as a factor of column labels (created if necessary) rather than as numbers

**Example 1:**

`# R program to illustrate ` `# row function ` ` ` `# Initializing a matrix with ` `# 2 rows and 2 columns ` `x <` `-` `matrix(c(` `1` `, ` `2` `, ` `3` `, ` `4` `), ` `2` `, ` `2` `) ` ` ` `# Getting the matrix representation ` `x ` ` ` `# Calling the row() function ` `row(x) ` |

*chevron_right*

*filter_none*

**Output:**

$Rscript main.r [, 1] [, 2] [1, ] 1 3 [2, ] 2 4 [, 1] [, 2] [1, ] 1 1 [2, ] 2 2

**Example 2:**

`# R program to illustrate ` `# row function ` ` ` `# Initializing a matrix with ` `# 3 rows and 3 columns ` `x <` `-` `matrix(rep(` `1` `:` `12` `), ` `3` `, ` `3` `) ` ` ` `# Getting the matrix representation ` `x ` ` ` `# Calling the row() function ` `row(x) ` |

*chevron_right*

*filter_none*

**Output:**

[, 1] [, 2] [, 3] [1, ] 1 4 7 [2, ] 2 5 8 [3, ] 3 6 9 [, 1] [, 2] [, 3] [1, ] 1 1 1 [2, ] 2 2 2 [3, ] 3 3 3

## Recommended Posts:

- Compute the Sum of Rows of a Matrix or Array in R Programming - rowSums Function
- Naming Rows and Columns of a Matrix in R Programming - rownames() and colnames() Function
- Get the position of the maximum element in each Row of a Matrix in R Programming - max.col() Function
- Getting a Matrix of number of columns in R Programming - col() Function
- Get the number of rows of an Object in R Programming - nrow() Function
- Getting the Modulus of the Determinant of a Matrix in R Programming - determinant() Function
- Getting the Determinant of the Matrix in R Programming - det() Function
- Combine Vectors, Matrix or Data Frames by Rows in R Language - rbind() Function
- Calculate the Mean of each Row of an Object in R Programming – rowMeans() Function
- Check if the Object is a Matrix in R Programming - is.matrix() Function
- Convert a Data Frame into a Numeric Matrix in R Programming - data.matrix() Function
- Convert an Object into a Matrix in R Programming - as.matrix() Function
- Changing row and column values of a Matrix in R Language - sweep() function
- Transform the Scaled Matrix to its Original Form in R Programming - Using Matrix Computations
- Getting and Setting Length of the Vectors in R Programming - length() Function
- Getting Match of an Element within a Vector in R Programming - charmatch() Function
- Getting class of different data types in R Programming - class() Function
- Getting type of different data types in R Programming - typeof() Function
- Getting String Representation of the given Date and Time Object in R Programming - strftime() Function
- Getting Kernel Density Estimates in R Programming - density() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.