Skip to content

Where is the construction of a dist object from raw data described?

2 messages · Steven Lembark, Gavin Simpson

#
Any reference to the appropriate documentation would
be most appreciated.

I am using the TSP module for clustering of HIV
genetic sequences. The distances have already been
computed and available as either upper-triangular
or square, i.e.:

    a  1 2 3
    b  4 5
    c  6
    d

or 

    a 0 1 2 3
    b 1 0 4 5
    c 2 4 0 6
    d 3 5 6 0

The TSP modules takes in a "dist" object.

Catch: The only way I can see to get a dist
object is with dist(), which computes the 
distances for itself rather than taking them
as-is.

Q: How does one convert either of the strucutres
   above into a "dist" object without having to 
   first feed them through dist()?

I can easily split the labels into a seprate
output file, leaving me with the rownames 
and colnames values for the result in a separate
place if that makes explaining how to get the 
numeric values into a dist any easier.

Google, searching r-project.org, and the R
Nutshell book all lead me back to dist() or 
daisy().

thanks

--
Steven Lembark                                          85-09 90th St.
Workhorse Computing                               Woodhaven, NY, 11421
lembark at wrkhors.com                                    +1 888 359 3508
#
On Wed, 2010-05-19 at 10:10 -0400, Steven Lembark wrote:
as.dist() will convert the square matrix into a dist object

I'm not sure of a convenient way of importing data in the "upper" form
you show without having to go via a matrix, or build the dist object by
hand, so if this really is an either/or situation and the square form is
always available and it is not a problem loading the dissimilarity
matrix into RAM, I'd stick with as.dist.

HTH

G