I've looked everywhere but could find an answer.
I have to numerical matrix a
1 2 3
4 5 6
and b
3 1 4
5 2 1
and would like to get c equal to the minimum pairwise values of a and b
c
1 1 3
4 2 1
Thanks
I've looked everywhere but could find an answer.
I have to numerical matrix a
1 2 3
4 5 6
and b
3 1 4
5 2 1
and would like to get c equal to the minimum pairwise values of a and b
c
1 1 3
4 2 1
Thanks
You can use pmin
, i.e.
pmin(m1, m2)
# [,1] [,2] [,3]
#[1,] 1 1 3
#[2,] 4 2 1
DATA:
m1 <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 3, byrow = TRUE)
m2 <- matrix(c(3, 1, 4, 5, 2, 1), ncol = 3, byrow = TRUE)