[R] dist

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Nov 19 15:08:58 CET 2001


On Mon, 19 Nov 2001, Agustin Lobo wrote:

>
> Hi list!
>
> I'm computing multivar. distances from a set of centroids
> to a (large) set of individuals. I'm now just using rbind
> to create a matrix (x) with the centroid and the individuals,
> then run as.matrix(dist(x)) and finally select the appropriate columns,
> as I'm not interested on the distances among individuals.
> Therefore, this procedure implies a waste of computing time.
> Is there any way to use dist only between each individual
> and the centroids (avoiding loops in R)? or should I just go and try to
> make
> a modified version of dist by hacking the C code?

You don't need C code for this.  Take a look at e.g. predict.lda and
predict.qda.  You might want to do the individuals in batches if the
number really is large (millions?).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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