Bug 15364 - stats::kmeans() stalls
stats::kmeans() stalls
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Analyses
R 3.0.0
x86_64/x64/amd64 (64-bit) Linux
: P5 major
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-26 23:45 UTC by gibberwocky
Modified: 2013-07-19 14:45 UTC (History)
1 user (show)

See Also:


Attachments
data stored in pca.pred[,1] (26.37 KB, application/octet-stream)
2013-06-26 23:45 UTC, gibberwocky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gibberwocky 2013-06-26 23:45:29 UTC
Created attachment 1459 [details]
data stored in pca.pred[,1]

The kmeans() function of the stats package stalls/hangs under the following circumstances:

tmp <- kmeans(pca.pred[,1], centers=2, nstart=10)

I have attached a copy of the data stored in pca.pred[,1]. It appears that the lack of variance in the samples might be causing the calculation to stall for whatever reason.
Comment 1 gibberwocky 2013-06-27 12:39:05 UTC
The same data and function appears to work OK under R.2.15...
Comment 2 gibberwocky 2013-06-27 13:24:51 UTC
I've just installed R v2.15.3 on a different machine (same OS, Linux 12.04 LTS), and it stalls. So the situation seems more complicated than first thought.
Comment 3 gibberwocky 2013-06-27 14:20:58 UTC
The machine on which this works is actually running R v2.15.2 not 2.15.3 as previously thought. I've since tried R v2.15.2 on the other machine and it still stalls.

This all seems reminiscent of an issue that was previously reported:

https://stat.ethz.ch/pipermail/r-help//2013-February/347175.html
Comment 4 Martin Maechler 2013-06-27 16:38:16 UTC
Thank you; your example is (strictly speaking not completely) reproducible
for me on my Linux desktop....
so it should be easy to fix.

I'm having a go at it.
Martin
Comment 5 Martin Maechler 2013-07-01 13:42:19 UTC
(In reply to comment #4)
> Thank you; your example is (strictly speaking not completely) reproducible
> for me on my Linux desktop....
> so it should be easy to fix.
> 
> I'm having a go at it.

It's a rounding / precision problem that I can reproduce .. only on 64-bit BTW.
I've decided to *not* add numerical fuzz .. which would potentially also change cases that have been working previously.
Rather, we now catch too many 'steps' in the QTRAns routine.
Committed to R-devel and R '3.0.1 patched"

Martin