Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以文本/表格格式显示TraMineR(R)树状图_R_Cluster Analysis_Dendrogram_Traminer - Fatal编程技术网

以文本/表格格式显示TraMineR(R)树状图

以文本/表格格式显示TraMineR(R)树状图,r,cluster-analysis,dendrogram,traminer,R,Cluster Analysis,Dendrogram,Traminer,我使用以下R代码生成一个树状图(见附图),带有基于TraMineR序列的标签: library(TraMineR) library(cluster) clusterward <- agnes(twitter.om, diss = TRUE, method = "ward") plot(clusterward, which.plots = 2, labels=colnames(twitter_sequences)) 库(TraMineR) 图书馆(群集) 群集问题涉及群集包。由agnes返

我使用以下R代码生成一个树状图(见附图),带有基于TraMineR序列的标签:

library(TraMineR)
library(cluster)
clusterward <- agnes(twitter.om, diss = TRUE, method = "ward")
plot(clusterward, which.plots = 2, labels=colnames(twitter_sequences))
库(TraMineR)
图书馆(群集)

群集问题涉及
群集
包。由
agnes
返回的
agnes.object
的帮助页面 (请参阅)说明此对象包含一个类似于
order
order.lab
组件,但包含观察标签而不是观察编号。此组件仅在标记原始观察时可用。”

TraMineR生成的相异性矩阵(
twitter.om
,在您的例子中)当前没有将序列标签保留为行名和列名。要获取
order.lab
组件,您必须手动将序列标签分配为
twitter.om
矩阵的
rownames
colnames
。我在这里用TraMineR包提供的
mvad
数据进行说明

library(TraMineR)
data(mvad)
## attaching row labels 
rownames(mvad) <- paste("seq",rownames(mvad),sep="")
mvad.seq <- seqdef(mvad[17:86]) 
## computing the dissimilarity matrix
dist.om <- seqdist(mvad.seq, method = "OM", indel = 1, sm = "TRATE")
## assigning row and column labels 
rownames(dist.om) <- rownames(mvad) 
colnames(dist.om) <- rownames(mvad) 
dist.om[1:6,1:6]

## Hierarchical cluster with agnes library(cluster) 
cward <- agnes(dist.om, diss = TRUE, method = "ward")

## here we can see that cward has an order.lab component 
attributes(cward)

希望这有帮助。

非常感谢!这很有帮助!
## plot the dendrogram
plot(cward, which.plot = 2, labels=FALSE)

## and select the groups manually from the plot
x <- identify(as.hclust(cward)) ## Terminate with second mouse button

## number of groups selected
length(x)
## list of members of the first group
x[[1]]