Skip to contents

Given a matrix, it returns a dataframe with two column: - first column are max values for each row of the original matrix - second column are indices of max values

Usage

rowMax(mat)

Arguments

mat

numeric matrix

Value

A dataframe with values and indices of max for each row

Examples

mat <- matrix(1:9, nrow = 3)
mat
#>      [,1] [,2] [,3]
#> [1,]    1    4    7
#> [2,]    2    5    8
#> [3,]    3    6    9

rowMax(mat)
#>   value index
#> 1     7     3
#> 2     8     3
#> 3     9     3