[R] faster vector subtraction??
Achim Zeileis
zeileis at ci.tuwien.ac.at
Wed Jan 16 21:48:47 CET 2002
Søren Merser wrote:
>
> hi
> is there a faster way to do this?
>
> i <- 1
> for(x in vector1)
> for(y in vector2) {
> m[[i]] <- (x - y)
> i <- i + 1
> }
I'm not completely sure, what you want, but this might give the desired
answer:
outer(vector1, vector2, FUN = "-")
Hope that helps
Z
> regards soren
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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