[R] outer()

Nancy Lo Nancy.Lo at noaa.gov
Fri Feb 15 01:04:40 CET 2002


Hi all,

I tried to use outer() but it gave me wrong answer. Anyone can tell me
why?  Thank you for your time.


> outer(a[1],b[1:2],f)
        [,1]    [,2]
[1,] 6903.15 6903.15

where
> a
[1] 0.5 2.0 4.0
> b
[1] -0.5 -1.5

> f
function(a1,b1){mleop4.fun(c(a1,b1,A[1],B[1],f1[1],f2[1],g[1],h[1]))}


The answer should be  6869.808,  6809.302

as shown below:

> outer(a[1],b[1],f)
         [,1]
[1,] 6869.808
> outer(a[1],b[2],f)
         [,1]
[1,] 6809.302

Or
> f(a[1],b[1])
[1] 6869.808
> f(a[1],b[2])
[1] 6809.302
>


Nancy

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list