[R] outer

K Fung fungile at yahoo.com
Thu Apr 29 06:41:21 CEST 2004


Hello,

Can anyone help explain why the following are not
equivalent?

I have written a function called cord.mag(x,y) which
takes two numbers and outputs a number.

Further I defined m=1:5, n=1:26

>  for(i in m) { for (j in n) print(cord.mag(i,j))}

this prints the m*n values, one on each line properly

> outer(m,n,cord.mag)

this gives me a matrix of zeroes

> outer(1,2,cord.mag)

this gives the right value on the other hand

Thanks




More information about the R-help mailing list