Skip to content
Prev 384103 / 398502 Next

struggling with apply

Hello,

Try pmin. And loop by column/UB index with sapply/seq_along.


sapply(seq_along(UB), function(i) pmin(UB[i], somematrix[,i]))
#     [,1] [,2] [,3] [,4]
#[1,]  1.0  5.5  8.5  7.0
#[2,]  2.5  3.0  8.0 10.5
#[3,]  2.5  5.5  5.0 10.5


Hope this helps,

Rui Barradas


?s 18:46 de 27/05/20, Michael Ashton escreveu: