Fredrik Lundgren wrote:

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?

Misunderstand what 'apply' does perhaps?


It applies your function to columns (the '2') of the matrix, and so the function should only expect one argument, for example:

> apply(mat, 2, function(e1){print(e1)})
[1]  5 17
[1]  7 28
[1]  6 36
[1]  7 41
[1]  8 46
[1]  10 140

- in this toy example,my function is called with e1 set to columns of the matrix.

So what were you trying to do with apply(mat, 2, function(e1,e2) e1*e2)?

Baz

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to