[R] hclust question

Winfried Theis theis at statistik.uni-dortmund.de
Fri Feb 23 10:06:02 CET 2001


Dear Ranjan,
On 23-Feb-01 Ranjan Maitra wrote:
> Dear all,
> 
> I have a question with regard to the use of hclust. I would like to be
> able to specify my own distance matrix instead of asking R to compute
> the distance matrix for me. It is computationally easier for me this
> way. My question is: How can I get hclust to accept this?
Have a look at the help page of dist:
Value

An object of class "dist". 
The lower triangle of the distance matrix stored by columns in a single vector.
The vector has the attributes "Size", "Diag", "Upper", "Labels" and
"class" equal to "dist".

So you have to shape your result according to this, when you got your vector d
you can add the attributes & class by

 attr(d, "Size") <- N
    attr(d, "Labels") <- dimnames(x)[[1]]
    attr(d, "Diag") <- diag
    attr(d, "Upper") <- upper
    attr(d, "method") <- METHODS[method]
    attr(d, "call") <- match.call()
    class(d) <- "dist"
  
(cited from the code of dist)

Regards, Winfried

> 
> Thanks,
> Ranjan
> 
> -- 
>  ***************************************************************************
>           Ranjan Maitra, Department of Mathematics and Statistics,
>      University of Maryland, Baltimore County, Baltimore, MD 21250, USA.
>  ***************************************************************************
> 
>   \|/         satyamevajayate         |      tamasomaajyotirgamaya      \|/
>   -*-                                 |                                 -*-
>   /|\       TRUTH SHALL PREVAIL       |      FROM DARKNESS TO LIGHT     /|\
> 
>  ***************************************************************************
>    Ph: 410-455-2436   FAX: 410-455-1066   http://www.math.umbc.edu/~maitra
>  ***************************************************************************
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> _

----------------------------------
E-Mail: Winfried Theis <theis at statistik.uni-dortmund.de>
Date: 23-Feb-01
Time: 09:58:31
Dipl.-Math. Winfried Theis, Fachbereich Statistik, Graduiertenkolleg
"Angewandte Statistik"
Universität Dortmund, 44221 Dortmund
Tel.: +49-231-755-5903  FAX: +49-231-755-4387
----------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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