RowMax | R Documentation |
Maximum of Matrix Rows
RowMax(x)
x |
input value (numeric) |
output value (numeric)
# generate a matrix of integers (also works for floats)
set.seed(0)
M = matrix(floor(runif(9, min=0, max=3)),
nrow=3,
ncol=3)
print(M)
# this outputs
# [,1] [,2] [,3]
# [1,] 2 1 2
# [2,] 0 2 2
# [3,] 1 0 1
# apply RowMax() to the matrix M, reformat output as matrix again
# to keep the maxs on their corresponding rows
RowMax(M)
# this outputs
# [,1]
# [1,] 2
# [2,] 2
# [3,] 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.