ClusterRedefine: Redefines Clustering

View source: R/ClusterRedefine.R

ClusterRedefineR Documentation

Redefines Clustering

Description

Redefines some or all labels in a clustering according to a supplied mapping.

Usage

ClusterRedefine(Cls, NewLabels,OldLabels,Silent=FALSE)

Arguments

Cls

1:n numerical vector of numbers defining the classification as the main output of the clustering algorithm for the n cases of data. It has k unique numbers representing the arbitrary labels of the clustering.

NewLabels

[1:p], p<=k labels (identifiers) of clusters to be changed with

OldLabels

Optional vector of p labels, with p <= k, identifying the clusters to change. The default is all unique cluster labels in Cls.

Silent

Optional logical scalar. If TRUE, warning messages are suppressed.

Details

The same ordering of NewLabels and OldLabels is assumed; that is, the mapping is OldLabels[i] -> NewLabels[i] for i in [1:p]. NewLabels may also be a character vector, for example for plotting.

Value

Cls[1:n] numerical vector named after the row names of data

Author(s)

Michael Thrun

Examples

data('Lsun3D')
Cls=Lsun3D$Cls
Data=Lsun3D$Data#
#prior
ClsNew=unique(Cls)+10
#Redfined Clustering
NewCls=ClusterRedefine(Cls,ClsNew)

table(Cls,NewCls)

#require(DataVisualizations)
n=length(unique(Cls))
NewCls=ClusterRedefine(Cls,LETTERS[1:n])
#DataVisualizations package required
if(requireNamespace("DataVisualizations"))
  DataVisualizations::Classplot(Data[,1],Data[,2],
  Cls,Names=NewCls,Plotter="ggplot",Size =1.5)


FCPS documentation built on Oct. 3, 2026, 9:06 a.m.