Learn R Programming

optpart (version 3.0-3)

silhouette.partana: Produce a Silhouette Object From a Partana, Clustering, or Stride Object

Description

Extracts components from a partana, clustering, or stride object, and passes the values to the silhouette function to produce an object of class silhouette.

Usage

# S3 method for partana
silhouette(x, dist, …)
# S3 method for clustering
silhouette(x, dist, …)
# S3 method for stride
silhouette(x, dist, …)
testsil(sil)

Arguments

x

an object of class ‘partana’, ‘clustering’, or ‘stride’

dist

an object of class dist

miscellaneous arguments to pass to function silhouette

sil

an object of class ‘silhouette’

Value

An object of class silhouette

Details

For ‘partana’ and ‘clustering’ objects the advantage over calling silhouette directly is that the row.names of the resulting object are added to the results, as opposed to consecutive integers.

For objects of class ‘stride’ the function extracts the component ‘clustering’ for each level of a stride object, and calls function silhouette in library ‘cluster’ returniung the mean silhouette width for each case.

testsil identifies ‘misfits’ in a partition, defined as plots with a negative silhouette width, and prints them out in a sorted list.

References

http://ecology.msu.montana.edu/labdsv/R

See Also

silhouette

Examples

Run this code
# NOT RUN {
data(shoshveg)             # produces a data frame of vegetation data, 
                           #samples as rows, attributes as columns
dis.bc <- dsvdis(shoshveg,'bray/curtis') # produces a Bray/Curtis 
                                         # dissimilarity matrix
opt.5 <- optpart(5,dis.bc) # produces an optimal partitioning into 
                           # 5 clusters
silhouette(opt.5,dis.bc)   # calculates the silhouette values
# }
# NOT RUN {
plot(silhouette(opt.5,dis.bc))
# }
# NOT RUN {
 # produce silhouette 
                                         # plot on current device
# }

Run the code above in your browser using DataLab