[datatable-help] sorting on floating point column

Ricardo Saporta saporta at scarletmail.rutgers.edu
Tue Apr 30 16:09:03 CEST 2013


I'm seeing the same thing as Arun:


> dt[, diffs := round(c(NA, diff(y) * 1e8), 3)]
> dt
     x            y         diffs
 1: 19 4.594595e-08            NA
 2: 17 7.007007e-08         2.412
 3: 45 3.543544e-08        -3.463
 4: 38 6.326326e-08         2.783
 5: 23 7.847848e-08         1.522
 6: 46 5.975976e-08        -1.872
 7:  3 3.073073e-08        -2.903
 8:  4 9.909910e-08         6.837
 9: 16 5.535536e-08        -4.374
10: 25 9.609610e-08         4.074
11: 24 9.309309e-08        -0.300
12: 12 7.000022e-01  70000210.691
13: 31 3.453453e-08 -70000216.547
14: 34 5.565566e-08         2.112
15: 14 1.241241e-08        -4.324


On Tue, Apr 30, 2013 at 9:52 AM, Arunkumar Srinivasan <aragorn168b at gmail.com
> wrote:

>  Hi there,
>
> I just saw something strange when I was sorting a column of p-values. I
> checked the data.table bug tracker for words "sort" and "floating point"
> and there were no hits for this case. There's a bug for "integer 64" sort
> on a column though.
>
> So, here's a reproducible example. I'd be glad to file a bug, if it is and
> be corrected if it's something I am doing wrong.
>
> set.seed(45)
> dt <- data.table(x=sample(50), y= sample(c(seq(0, 1, length.out=1000),
> 7000000:7000100), 50)/1e7)
> head(dt)
>     x            y
> 1: 32 5.395395e-08
> 2: 16 6.956957e-08
> 3: 12 2.142142e-08
> 4: 18 5.855856e-08
> 5: 17 6.216216e-08
> 6: 14 5.025025e-08
> setkey(dt, "y") # sort by column y
> head(dt, 10)
>      x            y
>  1: 47 1.401401e-09
>  2: 12 2.142142e-08
>  3: 24 1.391391e-08
>  4: 43 9.809810e-09 <~~~ obviously false
>  5:  1 2.932933e-08
>  6: 48 2.562563e-08
>  7: 49 1.891892e-08
>  8: 40 2.182182e-08
>  9:  9 7.307307e-09 <~~~ obviously false
> 10: 45 2.482482e-08
>
> Best,
> Arun
>
>
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130430/dd714dcf/attachment-0001.html>


More information about the datatable-help mailing list