Naming Rows and Columns of a Matrix in R Programming - rownames() and colnames() Function Last Updated : 05 Jun, 2020 Comments Improve Suggest changes Like Article Like Report rownames() function in R Language is used to set the names to rows of a matrix. Syntax: rownames(x) <- value Parameters: x: Matrix value: Vector of names to be set Example: Python3 1== # R program to provide a name # to rows of a Matrix # Creating a 3X3 Matrix A = matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE) # Calling rownames() Function rownames(A) <- letters[1:3] print(A) Output: [, 1] [, 2] [, 3] a 1 2 3 b 4 5 6 c 7 8 9 colnames() Function colnames() function in R Language is used to set the names to columns of a matrix. Syntax: colnames(x) <- value Parameters: x: Matrix value: Vector of names to be set Example: Python3 1== # R program to provide a name # to columns of a Matrix # Creating a 3X3 Matrix A = matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE) # Calling colnames() Function colnames(A) <- letters[1:3] print(A) Output: a b c [1, ] 1 2 3 [2, ] 4 5 6 [3, ] 7 8 9 Comment More infoAdvertise with us Next Article Naming Rows and Columns of a Matrix in R Programming - rownames() and colnames() Function N nidhi_biet Follow Improve Article Tags : R Language R Matrix-Function Similar Reads Calculate the Sum of Matrix or Array columns in R Programming - colSums() Function colSums() function in R Language is used to compute the sums of matrix or array columns. Syntax: colSums (x, na.rm = FALSE, dims = 1) Parameters: x: matrix or array dims: this is integer value whose dimensions are regarded as âcolumnsâ to sum over. It is over dimensions 1:dims. Example 1: Python3 # 2 min read Compute the Sum of Rows of a Matrix or Array in R Programming - rowSums Function rowSums() function in R Programming Language is used to compute the sum of rows of a matrix or an array. It simplifies the process of calculating the sum for each row, especially when dealing with large datasets, and can be applied to both numeric and logical data types.Syntax:rowSums(x, na.rm = FAL 3 min read Getting a Matrix of number of columns in R Programming - col() Function col() function in R Language is used to get a matrix which contains the number of columns of the matrix passed to it as argument. Syntax: col(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 2 min read Getting a Matrix of number of rows in R Programming - row() Function In this article, we will discuss how to find the number of rows and columns in a matrix in R Programming Language. nrow() Function in Rnrow() function in R Language is used to get the row number of a matrix. Syntax: row(x, as.factor=FALSE) Parameters:x: matrixas.factor: a logical value indicating w 2 min read Remove names or dimnames from an Object in R Programming - unname() Function unname() function in R Language is used to remove the names or dimnames from an Object. Syntax: unname(x) Parameters: x: Object Example 1: Python3 1== # R Program to remove names from an object # Creating a matrix A = matrix(c(1:9), 3, 3) # Naming rows rownames(A) = c("a", "b", 1 min read Like