[R] problems with outer (remainder of reply...)

Bill Venables Bill.Venables at cmis.csiro.au
Sun May 7 06:03:09 CEST 2000


[2nd go.  My previous message was suddenly dispatched before I had
finished.  Sorry about that - MicroSoft again, Sheesh!]

At 10:57 PM 5/6/00 -0400, Faheem Mitha wrote:

>
>Cam some kind person in any case confirm that this is what was meant?
>
>f.vect <- function(x,y) sapply(seq(along=x),function(i)f(x[i],y[i]))
>
>seems to be to only work correctly if x and y are the same length.

Yes it will handle it, but it may not speed things up very much.

You can think of outer as first doing a special kind of recycling, (the
same kind as is done in exapnd.grid in fact), calling the function you
supply once with expanded vector arguments with equal length and
re-arranging the result back into a matrix of the same form.

How do I know this?  I looked at the code for outer()!  It's only a couple
of lines long.

Bill Venables.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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