reorder.dendrogramを使用して樹状図を並べ替えたいのですが、パラメーターの設定方法について頭を曲げることができません。
樹状図には「外れ値」の分岐が1つあり、これを反対側に移動します。
このカット/マージ呼び出しでそれを行うことができますが、確かに再注文で可能ですか?
樹状図は次のとおりです。
tdro <- structure(list(structure(9L, members = 1L, height = 0, label = "leaf1", leaf = TRUE, class = "dendrogram"),
structure(list(structure(list(structure(list(structure(list(
structure(15L, label = "leaf2", members = 1L, height = 0, leaf = TRUE, class = "dendrogram"),
structure(14L, label = "leaf3", members = 1L, height = 0, leaf = TRUE, class = "dendrogram")), members = 2L, midpoint = 0.5, height = 24.8381484584436, class = "dendrogram"),
structure(list(structure(13L, label = "leaf4", members = 1L, height = 0, leaf = TRUE, class = "dendrogram"),
structure(12L, label = "leaf5", members = 1L, height = 0, leaf = TRUE, class = "dendrogram")), members = 2L, midpoint = 0.5, height = 24.3975287023022, class = "dendrogram")), members = 4L, midpoint = 1.5, height = 33.1101361501252, class = "dendrogram"),
structure(list(structure(10L, members = 1L, height = 0, label = "leaf6", leaf = TRUE, class = "dendrogram"),
structure(list(structure(11L, label = "leaf7", members = 1L, height = 0, leaf = TRUE, class = "dendrogram"),
structure(8L, label = "leaf8", members = 1L, height = 0, leaf = TRUE, class = "dendrogram")), members = 2L, midpoint = 0.5, height = 30.9363490461899, class = "dendrogram")), members = 3L, midpoint = 0.75, height = 32.3912839969328, class = "dendrogram")), members = 7L, midpoint = 3.125, height = 36.9011152635297, class = "dendrogram"),
structure(list(structure(5L, members = 1L, height = 0, label = "leaf9", leaf = TRUE, class = "dendrogram"),
structure(list(structure(list(structure(4L, members = 1L, height = 0, label = "leaf10", leaf = TRUE, class = "dendrogram"),
structure(list(structure(2L, label = "leaf11", members = 1L, height = 0, leaf = TRUE, class = "dendrogram"),
structure(6L, label = "leaf12", members = 1L, height = 0, leaf = TRUE, class = "dendrogram")), members = 2L, midpoint = 0.5, height = 20.537001267289, class = "dendrogram")), members = 3L, midpoint = 0.75, height = 27.9153607968991, class = "dendrogram"),
structure(list(structure(list(structure(7L, label = "leaf13", members = 1L, height = 0, leaf = TRUE, class = "dendrogram"),
structure(3L, label = "leaf14", members = 1L, height = 0, leaf = TRUE, class = "dendrogram")), members = 2L, midpoint = 0.5, height = 19.3278637150999, class = "dendrogram"),
structure(1L, members = 1L, height = 0, label = "leaf15", leaf = TRUE, class = "dendrogram")), members = 3L, midpoint = 1.25, height = 27.6624008548179, class = "dendrogram")), members = 6L, midpoint = 2.5, height = 30.8706298846279, class = "dendrogram")), members = 7L, midpoint = 1.75, height = 41.426993488228, class = "dendrogram")), members = 14L, midpoint = 5.9375, height = 41.7600747862578, class = "dendrogram")), members = 15L, midpoint = 3.46875, height = 66.2893195420674, class = "dendrogram")
plot(tdro)
これが私が求めているものです:
ddr_cut <- cut(tdro, 50)
want_tdro <- merge(ddr_cut$lower[[2]],
ddr_cut$lower[[1]],
height=attr(ddr_cut$upper, "height"))
plot(want_tdro)
問題は、次の呼び出しがどのように見えるかです。
plot(reorder(tdro, c(15,1:14)))
なるようにwant_tdro
?そして、なぜですか?