| as.seqtree | R Documentation |
Convert a hierarchical clustering object to a seqtree object which can then be displayed using seqtreedisplay.
as.seqtree(object, seqdata, diss, weighted=TRUE, ...)
## S3 method for class 'twins'
as.seqtree(object, seqdata, diss, weighted=TRUE, ncluster, ...)
## S3 method for class 'hclust'
as.seqtree(object, seqdata, diss, weighted=TRUE, ncluster, ...)
object |
An object to be converted to a |
seqdata |
State sequence object. |
diss |
A dissimilarity matrix or a dist object (see |
weighted |
Logical. If |
ncluster |
Maximum number of cluster. The tree will be builded until this number of cluster. |
... |
Additionnal parameters passed to/from methods. |
By default as.seqtree try to convert the object to a data.frame assuming that it contains a list of nested clustering solutions.
Be aware that seqtree and as.seqtree only support binary splits.
If object is an hclust or twins objects (i.e. hierarchical clustering output, see hclust, diana or agnes), the function returns a seqtree object reproducing the agglomerative schedulde.
A seqtree object.
data(mvad)
## Aggregating state sequence
aggMvad <- wcAggregateCases(mvad[, 17:86], weights=mvad$weight)
## Creating state sequence object
mvad.seq <- seqdef(mvad[aggMvad$aggIndex, 17:86], weights=aggMvad$aggWeights)
## COmpute distance using Hamming distance
diss <- seqdist(mvad.seq, method="HAM")
## Ward clustering
wardCluster <- hclust(as.dist(diss), method="ward", members=aggMvad$weight)
st <- as.seqtree(wardCluster, seqdata=mvad.seq, diss=diss, weighted=TRUE, ncluster=10)
print(st)
## You typically want to run (You need to install GraphViz before)
## seqtreedisplay(st, type="d", border=NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.