# predict.cclust: Assign clusters to new data In cclust: Convex Clustering Methods and Clustering Indexes

## Description

Assigns each data point (row in `newdata`) the cluster corresponding to the closest center found in `object`.

## Usage

 ```1 2``` ```## S3 method for class 'cclust' predict(object, newdata, ...) ```

## Arguments

 `object` Object of class `"cclust"` returned by a clustering algorithm such as `cclust` `newdata` Data matrix where columns correspond to variables and rows to observations `...` currently not used

## Value

`predict.cclust` returns an object of class `"cclust"`. Only `size` is changed as compared to the argument `object`.

 `cluster` Vector containing the indices of the clusters where the data is mapped. `size` The number of data points in each cluster.

## Author(s)

`cclust`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19``` ```# a 2-dimensional example x<-rbind(matrix(rnorm(100,sd=0.3),ncol=2), matrix(rnorm(100,mean=1,sd=0.3),ncol=2)) cl<-cclust(x,2,20,verbose=TRUE,method="kmeans") plot(x, col=cl\$cluster) # a 3-dimensional example x<-rbind(matrix(rnorm(150,sd=0.3),ncol=3), matrix(rnorm(150,mean=1,sd=0.3),ncol=3), matrix(rnorm(150,mean=2,sd=0.3),ncol=3)) cl<-cclust(x,6,20,verbose=TRUE,method="kmeans") plot(x, col=cl\$cluster) # assign classes to some new data y<-rbind(matrix(rnorm(33,sd=0.3),ncol=3), matrix(rnorm(33,mean=1,sd=0.3),ncol=3), matrix(rnorm(3,mean=2,sd=0.3),ncol=3)) ycl<-predict(cl, y) plot(y, col=ycl\$cluster) ```