sjc.cluster(data, groupcount = NULL, method = c("hclust", "kmeans"), distance = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"), agglomeration = c("ward", "ward.D", "ward.D2", "single", "complete", "average", "mcquitty", "median", "centroid"), iter.max = 20, algorithm = c("Hartigan-Wong", "Lloyd", "MacQueen"))
data.frame
with variables that should be used for the
cluster analysis.method = "kmeans"
(see kmeans
for details on centers
argument).
If groupcount = NULL
and method = "kmeans"
, the optimal
amount of clusters is calculated using the gap statistics (see
sjc.kgap
). For method = "hclust"
, groupcount
needs to be specified. Following functions may be helpful for estimating
the amount of clusters:
sjc.elbow
to determine the group-count depending on the elbow-criterion.
method = "kmeans"
, use sjc.kgap
to determine the group-count according to the gap-statistic.
method = "hclust"
(hierarchical clustering, default), use sjc.dend
to inspect different cluster group solutions.
sjc.grpdisc
to inspect the goodness of grouping (accuracy of classification).
"kmeans"
), a
kmeans cluster analysis will be computed. Use "hclust"
to
compute a hierarchical cluster analysis. You can specify the
initial letters only.method = "hclust"
(for hierarchical
clustering). Must be one of "euclidean"
, "maximum"
, "manhattan"
,
"canberra"
, "binary"
or "minkowski"
. See dist
.
If is method = "kmeans"
this argument will be ignored.method = "hclust"
(for hierarchical
clustering). This should be one of "ward"
, "single"
, "complete"
, "average"
,
"mcquitty"
, "median"
or "centroid"
. Default is "ward"
(see hclust
).
If method = "kmeans"
this argument will be ignored. See 'Note'.method = "kmeans"
. See kmeans
for details on this argument.method = "kmeans"
. May be one of "Hartigan-Wong"
(default),
"Lloyd"
(used by SPSS), or "MacQueen"
. See kmeans
for details on this argument.sjc.grpdisc
-function to
check the goodness of classification.
The returned vector includes missing values, so it can be appended
to the original data frame data
.
# Hierarchical clustering of mtcars-dataset
groups <- sjc.cluster(mtcars, 5)
# K-means clustering of mtcars-dataset
groups <- sjc.cluster(mtcars, 5, method="k")
Run the code above in your browser using DataLab