plot_2d: 2-dimensional plots

View source: R/clustering_functions.R

plot_2dR Documentation

2-dimensional plots

Description

2-dimensional plots

Usage

plot_2d(data, clusters, centroids_medoids)

Arguments

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.

Details

This function plots the clusters using 2-dimensional data and medoids or centroids.

Value

a plot

Author(s)

Lampros Mouselimis

Examples


# 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)


ClusterR documentation built on June 22, 2024, 10:28 a.m.