Get the position of the maximum element in each Row of a Matrix in R Programming - max.col() Function Last Updated : 16 Jun, 2020 Comments Improve Suggest changes Like Article Like Report max.col() function in R Language check for maximum value in each row and returns the column no. for it. Syntax: max.col(x, ties.method) Parameters: x: Numeric matrix ties.method: It takes random, first, and last as value and returns the position accordingly in case of a tie. Example 1: Python3 1== # R program to find positions # of maximum elements of a matrix # Creating matrices m1 <- matrix(c(1:4), 2) m2 <- matrix(c(4, 1, 2, 3), 2) m3 <- matrix(c(1:9), 3, 3) # Calling max.col() function max.col(m1) max.col(m2) max.col(m3) Output: [1] 2 2 [1] 1 2 [1] 3 3 3 Example 2: Python3 1== # R program to find positions # of maximum elements of a matrix # Creating matrices m1 <- matrix(c(2, 3, 2, 4), 2) m2 <- matrix(c(2, 3, 2, 4), 2) m3 <- matrix(c(2, 3, 2, 4), 2) m1 # Calling max.col() function max.col(m1, ties.method = "random") max.col(m2, ties.method = "first") max.col(m3, ties.method = "last") Output: [, 1] [, 2] [1, ] 2 2 [2, ] 3 4 [1] 2 2 [1] 1 2 [1] 2 2 Comment More infoAdvertise with us Next Article Get the position of the maximum element in each Row of a Matrix in R Programming - max.col() Function N nidhi_biet Follow Improve Article Tags : R Language R Matrix-Function Similar Reads Get the Maximum element of an Object in R Programming - max() Function max() function in R Language is used to find the maximum element present in an object. This object can be a Vector, a list, a matrix, a data frame, etc.. Syntax: max(object, na.rm) Parameters: object: Vector, matrix, list, data frame, etc. na.rm: Boolean value to remove NA element. Example 1: Python 1 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 Get the Minimum element of an Object in R Programming - min() Function min() function in R Language is used to find the minimum element present in an object. This object can be a Vector, a list, a matrix, a data frame, etc.. Syntax: min(object, na.rm) Parameters: object: Vector, matrix, list, data frame, etc. na.rm: Boolean value to remove NA element. Example 1: Python 1 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 Get Transpose of a Matrix or Data Frame in R Programming - t() Function t() function in R Language is used to calculate transpose of a matrix or Data Frame. Syntax: t(x) Parameters: x: matrix or data frame Example 1: Python3 # R program to illustrate # t function # Getting R Biochemical Oxygen Demand Dataset BOD # Calling t() function t(BOD) Output: Time demand 1 1 8.3 1 min read Like