Can't I cluster a dataset into k clusters where k is exactly the number of
observations? I have version 12.2 installed. See this example
> a <- matrix(1:100, 20)
> kmeans(a, 20)
Error: number of cluster centres must lie between 1 and nrow(x)
This is a bit ad-hoc but I known R from version 2.12 allows number of
clusters to be one. So I guess allowing number of clusters to be nrow(x)
should be also possible in the future release?
Feng
--
Feng Li
Department of Statistics
Stockholm University
106 91 Stockholm, Sweden
http://feng.li/
[[alternative HTML version deleted]]
______________________________________________
R-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
I am writing a special algorithm to cluster some datasets with different
numbers of observations. For some particular datasets, there is only one
observation(e.g. people died of a rare disease). kmeans() thus will not work
at this situation.
Feng
2011/2/2 Rafael Björk <rafael...@gmail.com>
> If you change the algorithm, the function allow you to do this:
>
> > kmeans(a, 20,algorithm="Lloyd")
>
> Maybe i'm missing something here, but why would you want to create as many
> clusters as there are observations? Won't the outcome just be one
> observation in each cluster?