[R] unary operations

Fredrik Lundgren fredrik.lundgren at norrkoping.mail.telia.com
Tue Dec 23 09:59:35 CET 2003


Hello,

I had expected that the following should work

mat <- matrix(c(5, 7, 6, 7, 8, 10, 17, 28, 36, 41, 46, 140), nrow = 2, byrow = T)
mat

apply(mat, 2, function(e1,e2) e1*e2)
apply(mat, 2, function(e1,e2) e1+e2)
apply(mat, 2, function(e1,e2) e1-e2)
apply(mat, 2, function(e1,e2) e1/e2)

but I get 

Error in FUN(newX[, i], ...) : Argument "e2" is missing, with no default

What do I do wrong?

Sincerely Fredrik Lundgren




More information about the R-help mailing list