2013-12-08 114 views

回答

2

指定keep.dendro = TRUE,您應該有數據在RowvColv的列表元素下。

這是一個從?heatmap稍作修改的例子。

require(graphics); require(grDevices) 
x <- as.matrix(mtcars) 
rc <- rainbow(nrow(x), start = 0, end = .3) 
cc <- rainbow(ncol(x), start = 0, end = .3) 
hv <- heatmap(x, col = cm.colors(256), scale = "column", 
       RowSideColors = rc, ColSideColors = cc, margins = c(5,10), 
       xlab = "specification variables", ylab = "Car Models", 
       main = "heatmap(<Mtcars data>, ..., scale = \"column\")", 
       keep.dendro = TRUE) 

hv$Rowv 
'dendrogram' with 2 branches and 32 members total, at height 425.3447 

編輯

如果你想組成員,您需要先砍倒。

cutree(as.hclust(hv$Rowv), h = 200) 

      Mazda RX4  Mazda RX4 Wag   Datsun 710  Hornet 4 Drive Hornet Sportabout    Valiant 
        1     1     1     2     3     2 
     Duster 360   Merc 240D   Merc 230   Merc 280   Merc 280C   Merc 450SE 
        3     1     1     1     1     2 
     Merc 450SL   Merc 450SLC Cadillac Fleetwood Lincoln Continental Chrysler Imperial   Fiat 128 
        2     2     3     3     3     1 
     Honda Civic  Toyota Corolla  Toyota Corona Dodge Challenger   AMC Javelin   Camaro Z28 
        1     1     1     2     2     3 
    Pontiac Firebird   Fiat X1-9  Porsche 914-2  Lotus Europa  Ford Pantera L  Ferrari Dino 
        3     1     1     1     3     1 
     Maserati Bora   Volvo 142E 
        4     1 
+0

到目前爲止,這麼好。但是,我如何提取這些成員的具體名稱? –

+1

@TomA看到我的答案。 –