Re: [R] faster vector subtraction??

About this list Date view Thread view Subject view Author view Attachment view

From: Ben Bolker (ben@zoo.ufl.edu)
Date: Thu 17 Jan 2002 - 08:00:07 EST


Message-id: <Pine.LNX.4.30.0201161557090.21365-100000@bolker.zoo.ufl.edu>


  outer() is the basic answer:

  as.vector(t(outer(x,y,"-")))

 [ or as.list() if you really want it as a list ]

On Wed, 16 Jan 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
> }
>
> 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@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
318 Carr Hall                                bolker@zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 17 Jan 2002 - 11:10:11 EST