kclusters_simple | R Documentation |
A utilization of the kmeans
function to simplify k-means clustering of
2 variables.
kclusters_simple(x, y, k, ...)
x |
Formula. An expression of the form |
k |
Integer. The number of clusters to group the data into. |
stats::kmeans
# Use k-means to cluster football/soccer players by height and weight.
data(futbol)
kclusters(wt_lbs ~ ht_inches, data = futbol, k = 2)
# Include this data in the original data and plot it
futbol <- mutate(futbol, cluster = kclusters(wt_lbs ~ ht_inches, data = futbol, k = 2))
xyplot(wt_lbs ~ ht_inches, data = futbol, groups = cluster)
# We can compare the clustering to the actual
xyplot(wt_lbs ~ ht_inches, data = futbol, groups = league)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.