[R] Dengrogram Help (Custom Make)

mlell08 mlell08 at gmail.com
Wed Apr 10 14:01:33 CEST 2013


Hi,

this is how far I have come without practicel knowledge of dendrograms.

_________________________________________________________________________

# This dendrogram is from the demo of 'dendrogram', obtained by dput()!

d3 <- structure(list(structure(list(structure(8L, members = 1L,
height = 0, label = "Delaware", leaf = TRUE),
structure(list(structure(1L, label = "Alabama", members = 1L,
height = 0, leaf = TRUE), structure(18L, label = "Louisiana",
members = 1L, height = 0, leaf = TRUE)), members = 2L, midpoint = 0.5,
height = 15.4544491975612)), members = 3L, midpoint = 0.75,
height = 16.8914988216046),structure(list(structure(list(
structure(13L, label = "Illinois", members = 1L, height = 0,
leaf = TRUE),structure(32L, label = "New York", members = 1L,
height = 0, leaf = TRUE)), members = 2L, midpoint = 0.5,
height = 6.23698645180507),structure(list(structure(22L,
label = "Michigan", members = 1L, height = 0, leaf = TRUE),
structure(28L, label = "Nevada", members = 1L, height = 0,
leaf = TRUE)), members = 2L, midpoint = 0.5,
height = 13.2973681606549)), members = 4L, midpoint = 1.5,
height = 18.4173313943456)), members = 7L, midpoint = 2.625,
height = 26.3634282396782, class = "dendrogram")

plot(d3)

str(d3)
str(d3[[1]])
str(d3[[1]][[1]])

# The attributes of each node contain "midpoint" and "height" which are
# the x and y coordinates.
# par()$usr gives you the total coordinate range which can be seen in
# the plot.

attributes(d3[[1]])$midpoint
attributes(d3[[1]])$height

_______________________________________________________________________

We can't help you with your MatchPrint/MatchScore because we still
haven't got any code from you. It helps if you prepare a workin example
an put it in your email.

run dput() on a fraction of your dendrogram.
To obtain this fraction, use cut()

E.g. try
__________________________________
plot(cut(d3,h=20)$lower[[1]])
__________________________________
in the example above.

The result of
________________________________________________________
# Cut the tree at height 20 and take the first sub-tree
#
#       |
#     -------
#     |      |
#     |     --------
#     |     |      |
#________________________  <--h
#     |     |      |
#     |     |    ------
#   -----   |    |    |
#   |   |   |    |    |
#
#   [[1]]  [[2]] [[3]]
#      Sub-trees

dput(cut(d3,h=20)$lower[[1]]
__________________________________________________________
...can be assigned to a variable to restore the object given to dput()

Regards, Moritz

On 10.04.2013 05:07, gunturus wrote:
> But how would I get the coordinates of the leaves to draw a rectangle. And
> what about determining the size of the rectangle. I will have about 1000
> leaves, so it will hard to determine the size of the rectangle.
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Dengrogram-Help-Custom-Make-tp4663806p4663827.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.
> 


-- 
GnuPG Key: 0x7340821E



More information about the R-help mailing list