
On 9 May 2008, at 09:12, Jordan van Rijn wrote:

> Hello,
>
> I am hoping you can help me with a question concerning kmeans  
> clustering
> in R. I am working with the following data-set (abbreviated):
>
>
>         BMW Ford Infiniti Jeep Lexus Chrysler Mercedes Saab Porsche
>         Volvo
>   [1,]   6    8        2    8     4        5        4    4        
> 7     7
>   [2,]   8    7        4    6     4        1        6    7        
> 8     5
>   [3,]   8    2        4    6     3        2        7    4        
> 4     4
>   [4,]   7    4        4    6     6        1        6    3        
> 5     5
>   [5,]   6    2        4    5     5        1        3    3        
> 6     3
>   [6,]   6    7        3    6     5        1        8    4        
> 8     2
>   [7,]   1    6        6    7     5        2        6    6        
> 5     6
>   [8,]   3    6        6    4     5        1        4    2        
> 1     1
>   [9,]   6    7        5    8     4        1        6    6        
> 8     5
>  [10,]   6    7        5    9     3        1        2    5        
> 1     8
>
> When I try to scale my data and perform kmeans clustering, I get the
> following errors:
>  new <- scale(new)
> Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric

Probably the data is stored as factor instead of numeric.
Try coercing by as.numeric(new)
hth, Ingmar

>> cl <- kmeans(new, 4)
> Error in switch(nmeth, { : NA/NaN/Inf in foreign function call (arg 1)
> In addition: Warning message:
> In switch(nmeth, { : NAs introduced by coercion
>
> This is confusing to me since all of the data is numeric and there are
> no missing values. Is there something I need to do to my data to  
> prepare
> it for kmeans? I have tried many matrix transformations but nothing  
> has
> worked so far.
>
> Your help is much appreciated.
>
> Thanks,
>   jordan
>
> -- 
>   Jordan van Rijn
>   vanrijn9@fastmail.fm
>
> ______________________________________________
> R-help@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.

Ingmar Visser
Department of Psychology, University of Amsterdam
Roetersstraat 15
1018 WB Amsterdam
The Netherlands
t: +31-20-5256723



	[[alternative HTML version deleted]]

