代码之家  ›  专栏  ›  技术社区  ›  Leprechault

层次聚类树形图中响应变量的可视化

  •  2
  • Leprechault  · 技术社区  · 7 年前

    我想在层次聚类树图中表示响应变量“sepal.length”、“sepal.width”、“patal.length”和“patal.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)
    #
    

    Dedrogarm plot

    现在我不知道在树图的节点中表示变量“sepal.length”、“sepal.width”、“patal.length”和“patal.width”的代码有什么变化。有人能帮我吗? 谢谢

    1 回复  |  直到 7 年前
        1
  •  1
  •   Jari Oksanen    7 年前

    您不能表示变量。你有一个不同的观察矩阵(布雷柯蒂斯是一个不充分的不同度量),所有关于原始变量的信息将在不同的情况下丢失。