replace dist with mahalanobis distance in the following example.

a <- cbind(runif(10), sample(1:3, 10, replace=T))
a.L <- split(a,a[,2])
dist.L <- lapply(a.L, dist)



Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina

nikhil.l...@gmail.com

On Jul 19, 2010, at 9:24 AM, Michael Ralph M. Abrigo wrote:

Hi! I am trying to implement non-bipartite matching. I have around 500 sites
which can be clustered by 10 regions. I am able to calculate pairwise
Mahalanobis distances between sites (thanks to another post in the forum). However, I want to constrain my match to sites within the same region. Thus I want to replace elements of the distance matrix with a high value, say
999999, for sites not of the same region so that the pair will not be
matched.
In the original data file I have information on which sites belong to what region. However, when I compute for pairwise Mahalanobis distances, I only
use a subset of the file, which, naturally, does not include the
georeference of the sites. How should I do this? Any hint will be most
appreciated.
Btw, I am relatively new in using R. I may export the matrix to another program and replace the elements there, but that is a very very dirty and
rough trick that I would rather not do given better options.
Many thanks in advance.

Cheers,
Michael

--
"I am most anxious for liberties for our country... but I place as a prior
condition the education of the people so that our country may have an
individuality of its own and make itself worthy of liberties... " Jose
Rizal,1896

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to