我想用分层聚类树状图表示响应变量“ Sepal.Length”,“ Sepal.Width”,“ Petal.Length”和“ Petal.Width”,但不成功。我做的:
#Example with iris data set
library(vegan)
data(iris)
names(iris)
# [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
y <- as.matrix(iris[,-5])[6*(1:25),] # subsample to make the graphs
rownames(y) <- iris$Species[6*(1:25)] # pretty
#Calculate distance matrix using Bray
comm.pat.dist <- vegdist(y, method = "bray")
#Create a cluter using hclust
comm.bc.clust <- hclust(comm.pat.dist, method = "ward.D2")
# Plot cluster
hpat <- as.dendrogram(comm.bc.clust)
nodePar <- list(lab.cex = 0.6, pch = c(NA, 19),
cex = 0.7, col = "blue")
plot(hpat, ylab = "Bray dissimilarity",
nodePar = nodePar, cex=0.75, edgePar = list(col = 2:3, lwd = 2:1), horiz = TRUE)
#
现在我不知道在树状图的节点中表示变量“ Sepal.Length”,“ Sepal.Width”,“ Petal.Length”和“ Petal.Width”的代码发生了什么变化。任何成员都可以帮助我吗? 谢谢
答案 0 :(得分:1)
您不能表示变量。您有一个用于观察的相异性矩阵(而Bray-Curtis是一个不充分的相异性度量),所有有关原始变量的信息都将因相异性而丢失。