[R] outer problem
erich.neuwirth at univie.ac.at
Tue Jun 20 19:52:16 CEST 2000
i also looked into the definition of outer and now i understand what is
but now i have some more questions
on how to vectoruce functions.
lapply and sapply essentially allow to vectorise a fucntion with one
but is there a way of vectorizing a 2 argument function such that
the 2 arguments lists are "run through" sybchronously?
(mapcar (lambda (x y) (* x y)) (1 3 5) (2 4 6))
produces the list (1*2 3*4 5*6)
(not really, this is just a description of hiw it works).
lapply and sapply accept more than one list arguments,
but then work on the cross product.
will returns lists and arrays with 9 elements, not with 3 elements.
is there a "natural" way of running through lists in sync, like mapcar
> You're misunderstanding outer().
> outer(x,y,f) does just one call to f with arguments created by stacking x
> and y together in the right way, so f has to be vectorised.
> In any case, var(X) returns the covariance matrix of X, much more
> Thomas Lumley
> Assistant Professor, Biostatistics
> University of Washington, Seattle
Erich Neuwirth, Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-38624 Fax: +43-1-4277-9386
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