check_clustering | R Documentation |
check_clustering
checks whether a clustering satisfies constraints on
the size and composition of the clusters.
check_clustering(
clustering,
size_constraint = NULL,
type_labels = NULL,
type_constraints = NULL,
primary_data_points = NULL
)
clustering |
a |
size_constraint |
an integer with the required minimum cluster size. If |
type_labels |
a vector containing the type of each data point. May be |
type_constraints |
a named integer vector containing type-specific size constraints. If
|
primary_data_points |
a vector specifying primary data points, either by point indices or with
a logical vector of length equal to the number of points.
|
Returns TRUE
if clustering
satisfies the constraints, and
FALSE
if it does not. Throws an error if clustering
is an
invalid instance of the scclust
class.
See sc_clustering
for details on how to specify the
type_labels
and type_constraints
parameters.
# Example scclust clustering
my_scclust <- scclust(c("A", "A", "B", "C", "B",
"C", "C", "A", "B", "B"))
# Check so each cluster contains at least two data points
check_clustering(my_scclust, 2)
# > TRUE
# Check so each cluster contains at least four data points
check_clustering(my_scclust, 4)
# > FALSE
# Data point types
my_types <- factor(c("x", "y", "y", "z", "z",
"x", "y", "z", "x", "x"))
# Check so each cluster contains at least one point of each type
check_clustering(my_scclust,
NULL,
my_types,
c("x" = 1, "y" = 1, "z" = 1))
# > TRUE
# Check so each cluster contains one data point of both "x" and "z"
# and at least three points in total
check_clustering(my_scclust,
3,
my_types,
c("x" = 1, "z" = 1))
# > TRUE
# Check so each cluster contains five data points of type "y"
check_clustering(my_scclust,
NULL,
my_types,
c("y" = 5))
# > FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.