View source: R/clustering_functions.R
plot_2d | R Documentation |
2-dimensional plots
plot_2d(data, clusters, centroids_medoids)
data |
a 2-dimensional matrix or data frame |
clusters |
numeric vector of length equal to the number of rows of the data, which is the result of a clustering method |
centroids_medoids |
a matrix of centroids or medoids. The rows of the centroids_medoids should be equal to the length of the unique values of the clusters and the columns should be equal to the columns of the data. |
This function plots the clusters using 2-dimensional data and medoids or centroids.
a plot
Lampros Mouselimis
# data(dietary_survey_IBS)
# dat = dietary_survey_IBS[, -ncol(dietary_survey_IBS)]
# dat = center_scale(dat)
# pca_dat = stats::princomp(dat)$scores[, 1:2]
# km = KMeans_rcpp(pca_dat, clusters = 2, num_init = 5, max_iters = 100)
# plot_2d(pca_dat, km$clusters, km$centroids)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.