[R] problems with outer

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sun May 7 02:02:36 CEST 2000


Faheem Mitha <faheem at email.unc.edu> writes:

> Note that my function tempexpbinsumsq merely exists for the purpose of
> outer. I could have done 
> tempmatrix <-
> outer(x,y,function(x,y) expbinsumsq(point,pair,x,y,a,b,theta))
> but I don't know if that would be correct usage.
> 
> Can someone explain what is going on? I'm at my wits end.

The thing that usually tricks beginners with outer() is that the
function has to be vectorised. I.e. if you stick in vectors for x and
y, you get a vector result back. Otherwise, you have to vectorise it
yourself, e.g. if f takes scalar arguments,

f.vect <- function(x,y) sapply(seq(along=x),function(i)f(x[i],y[i]))

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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