Thomas Lumley <[EMAIL PROTECTED]> writes: > On Sun, 30 Oct 2005, Jonathan Rougier wrote: > > > I'm not sure about this. Perhaps I am a dinosaur, but my feeling is > > that if people are writing functions in R that might be subject to > > simple operations like outer products, then they ought to be writing > > vectorised functions! > > I would agree. How about an oapply() function that does multiway (rather > than just two-way) outer products. Basing the name on "apply" would > emphasize the similarity to other flexible, not particularly optimized > second-order functions.
In fairness, it should probably be said that not all problems vectorize naturally. One example is ssd <- function(A,alpha) sum((Y - A*exp(-alpha*t))^2) However, it should be worth noting that with the mapply() function at hand, it is pretty easy to turn a non-vectorized function into a vectorized one. SSD <- function(A,alpha) mapply(ssd, A, alpha) (Anybody want to try their hand on writing a general Vectorize() function? I.e. one that allowed outer(Avec, alphavec, Vectorize(ssd)) to work.) -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel