[R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Ffenics
Hi there I have been using R to perform kmeans on a dataset. The data is fed in using read.table and then a matrix (x) is created i.e: [ mat - matrix(0, nlevels(DF$V1), nlevels(DF$V2), dimnames = list(levels(DF$V1), levels(DF$V2))) mat[cbind(DF$V1, DF$V2)] - DF$V3 This matrix is then taken and

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Christian Hennig
First of all, kmeans doesn't work on distance matrices. On Mon, 7 Aug 2006, Ffenics wrote: Hi there I have been using R to perform kmeans on a dataset. The data is fed in using read.table and then a matrix (x) is created i.e: [ mat - matrix(0, nlevels(DF$V1), nlevels(DF$V2), dimnames =

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Ffenics
well then i dont understand because everything i have read so far suggests that you use the dist() function to create a matrix based on the euclideam distance and then the kmeans() function. If this is incorrect, then any suggestins as to how to do this properly would be much appreciated.

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Gabor Grothendieck
There are many clustering functions in R and R packages and some take distance objects whereas others do not. You likely read about hclust or some different clustering function. See ?kmeans for the kmeans function and also look at the CRAN Task View on clustering for other clustering functions:

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Ffenics
Thanks. I had a look at that and it says: Partitioning Clustering: Functionkmeans() from package stats provides several algorithms for computing partitions with respect to Euclidean distance.

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Gabor Grothendieck
?kmeans says the following. Note that x is a matrix of ***data***. Also look at the examples at the end of the help page if its still not clear. Usage: kmeans(x, centers, iter.max = 10, nstart = 1, algorithm = c(Hartigan-Wong, Lloyd, Forgy, MacQueen)) Arguments: x: A

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Ffenics
Thanks. i shall have a look see Gabor Grothendieck [EMAIL PROTECTED] wrote: ?kmeans says the following. Note that x is a matrix of ***data***. Also look at the examples at the end of the help page if its still not clear. Usage: kmeans(x, centers, iter.max = 10, nstart = 1,

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Ffenics
Thanks everyone for their help so far. I'm very appreciative of the fact that people have pointed out that I was heading in the wrong direction. I would be most grateful if someone could look over the following simple example for me and tell me if this is how to do it. I'm assuming by data matrix

Re: [R] kmeans and incom,plete distance matrix concern

2006-08-07 Thread Christian Hennig
Thanks everyone for their help so far. I'm very appreciative of the fact that people have pointed out that I was heading in the wrong direction. I would be most grateful if someone could look over the following simple example for me and tell me if this is how to do it. I'm assuming by data