[R] dissimilarity structure 
    Thomas Lumley 
    tlumley at u.washington.edu
       
    Tue Jul  3 17:28:03 CEST 2001
    
    
  
On Tue, 3 Jul 2001, Francois Deshaies wrote:
> How can I easily convert this format
>
> INT CAB 1.0000000
> LIG CAB 0.3333333
> TEN CAB 1.0000000
> INT LIG 1.0000000
> TEN LIG 1.0000000
> INT TEN 0.0000000
>
> to this dissimilarity structure  format(compatible with hclust) ?
>
>           CAB INT LIG
> INT 1.0000000
> LIG 0.3333333   1
> TEN 1.0000000   0   1
>
> (and vice versa)
One way is
  m<-matrix(ncol=4,nrow=4)
  m[lower.tri(m)]<-your.dissimilarity.vector
  as.dist(m)
In fact, dissimilarity objects are just vectors with some attributes,
[unclass() a dist object to see], so you could just put these attributes
on your vector.  This is stylistically a bad idea, since in theory the
internal structure of "dist" objects could change at any time, but it
would probably work.
	-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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