Skip to content
Prev 387314 / 398502 Next

Column-by-column division

Hello,

Maybe define an infix operator?


`%!%` <- function(x, y) {
   stopifnot(ncol(x) == length(y))
   t(t(x)/y)
}

x <- matrix(1:20, ncol = 2)
s <- 1:2

x %!% s
x %!% 1:4


Hope this helps,

Rui Barradas

?s 11:00 de 03/03/21, Steven Yen escreveu: