[R] hclust question

Friedrich Leisch Friedrich.Leisch at ci.tuwien.ac.at
Fri Feb 23 08:23:15 CET 2001


>>>>> On Thu, 22 Feb 2001 22:37:40 -0500 (EST),
>>>>> Ranjan Maitra (RM) 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?

simply use as.dist() to convert a matrix of distances to a distance
object.

e.g.:


## some arbitrary symmetric matrix x
R> x
          1         2         3         4         5
1 0.0000000 1.5705860 1.0434241 1.7699446 0.6694592
2 1.5705860 0.0000000 0.5271619 0.1993587 0.9011267
3 1.0434241 0.5271619 0.0000000 0.7265205 0.3739649
4 1.7699446 0.1993587 0.7265205 0.0000000 1.1004854
5 0.6694592 0.9011267 0.3739649 1.1004854 0.0000000
R> hclust(as.dist(x))

Call:
hclust(d = as.dist(x))

Cluster method   : complete 
Number of objects: 5 


hope this helps,

-- 
-------------------------------------------------------------------
                        Friedrich  Leisch 
Institut für Statistik                     Tel: (+43 1) 58801 10715
Technische Universität Wien                Fax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071      Friedrich.Leisch at ci.tuwien.ac.at
A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch
-------------------------------------------------------------------

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