[R] kmeans: invalid length argument
Lowell Gould
lowell.gould at spgenetics.com
Thu Feb 26 14:13:34 CET 2009
Dear R Experts,
I am running a cluter analysis using kmeans and have come across an error to which I am unable to find a solution. First, let me describe the problem:
THE R CODE IS:
--------------------------------------
# NRM is a 100 x 100 numerical matrix
infile = 't:\\NRM\\NRM'
groups = 7
outfile = 't:\\NRM\\cluster.groups'
print( paste(infile, groups, outfile, sep=' '))
pairs <- read.table(file=infile, header=TRUE, sep='')
names(pairs) <- row.names(pairs)
dist.pairs <- dist(pairs)
clust <- kmeans(dist.pairs, groups)
write.table(clust$cluster, file=outfile, quote=FALSE)
THE ERROR IS:
----------------------------------------
Error in vector("integer", length) : invalid 'length' argument
Calls: kmeans -> do_one -> switch -> integer -> vector Execution halted
I ran this code on a WindowsXP R6.2.6 host and it ran fine with acceptable results. However, the error ocurrs when I run it on CentOS (redhat 4.1.1-52) R2.7.2. The following search queries yielded no pertinent results from the web(Google), Google groups, R-help archives (Nabble and Namazu), and R-FAQ:
1. kmeans
2. invalid length argument
3. vector
?vector says that the length argument must be non-negative integer. But I don't know how to access that call to vector to see what is actually being used as an argument.
Any help on this matter will be greatly appreciated. Thank you for your time.
Lowell
-----------------------------------------------
Lowell Gould, Ph.D.
Smithfield Premium Genetics
316 W. Charity Rd.
Rose Hill, NC 28458
v. 910.282.4292
f. 910.289.6466
More information about the R-help
mailing list