do_cluster: K-Means Cluster

Description Usage Arguments Examples

Description

From beginning to end

Usage

1
2
do_cluster(df, vars, to_scale, n_centers = 5,
  algorithm = "Hartigan-Wong", trace = FALSE)

Arguments

df

A dataframe

vars

Variables from that dataframe to keep, some of which will be scaled and used for clustering.

to_scale

A subset of vars, all numeric, to be scaled and used for clustering.

n_centers

The number of clusters you want.

algorithm

kmeans algo to use

trace

Trace progress?

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
v <- names(iris)
t_s <- v[-which(v == "Species" | v == "Petal.Length")]

clustered_iris <- do_cluster(iris, vars = v, to_scale = t_s, n_centers = 3)
## Not run: 
ggplot(data = clustered_iris %>%
                  trim_outliers(exclude = c("cluster_assignment", "Species"))) +
  geom_text(aes(Sepal.Width_scaled, Sepal.Length_scaled,
                colour = cluster_assignment,
                label = Species)) +
  theme_bw()

## End(Not run)

aedobbyn/dobtools documentation built on May 28, 2019, 2:33 a.m.