美文网首页机器学习
聚类分析-R语言

聚类分析-R语言

作者: 育种数据分析之放飞自我 | 来源:发表于2018-07-28 21:06 被阅读14次

    1,原始数据,是矩阵,有行头和列名:


    data

    2,amap包的聚类分析:

    library(amap)
    clu <- hclusterpar(matx)
    plot(clu,sub="",hang = -1,xlab = NA,ylab = NA,main = NA)
    
    cluster

    用法:
    hcluster(x, method = "euclidean", diag = FALSE, upper = FALSE,
    link = "complete", members = NULL, nbproc = 2,
    doubleprecision = TRUE)

    3,cluster包

    library(cluster)
    agnx <- agnes(matx,method = "complete")
    pltree(agnx)
    

    agnes(x, diss = inherits(x, "dist"), metric = "euclidean",
    stand = FALSE, method = "average", par.method,
    keep.diss = n < 100, keep.data = !diss, trace.lev = 0)
    默认方法不一样,这里改为complete

    cluster2

    转化为横着排放的格式:

    dagn  <- as.dendrogram(as.hclust(agnx))
    plot(dagn, horiz = TRUE, center = TRUE,
         nodePar = list(lab.cex = 0.6, lab.col = "forest green", pch = NA),
         main = deparse(agn$call))
    
    图片.png

    相关文章

      网友评论

        本文标题:聚类分析-R语言

        本文链接:https://www.haomeiwen.com/subject/hwramftx.html