Sorting numeric DataTable fields with decimal separator

658 views
Skip to first unread message

Victor Kryukov

unread,
Jan 24, 2014, 6:56:45 PM1/24/14
to shiny-...@googlegroups.com
Hello,

I've encountered a very puzzling behavior when using DataTables (the javascript ones).

I have a data frame with numeric data where numeric columns are converted to characters with decimal separator, using format(round(x, 0), big.mark = ","). The resulting data frame is than feed to renderDataTable.

I'm receiving different results when sorting such columns in browser: on Mac and Windows, they are sorted properly (in increasing numerical orders), while on Linux (CentOs 5.9), they are sorted alphabetically . I made sure that R environments are exactly the same - same R version, same shiny library version (0.8.0), etc. 

We cannot use DataTable's sorting plugins[1] at the moment[2], it seems. renderDataTable has somewhat cryptic message in it's documentation string - "Paging, searching, filtering, and sorting can be done on the R side using Shiny as the server infrastructure". I'm not sure what exactly should I do to sort my numeric columns properly on the server side?

Any help on how to sort numeric columns with decimal separators properly would be much appreciated!

Victor

Victor Kryukov

unread,
Jan 29, 2014, 7:38:58 PM1/29/14
to shiny-...@googlegroups.com
So looks like nobody knows... For now, I just switched back to displaying numbers without a decimal separation. Looking forward for a improved DataTable support in the future versions of shiny!

Yihui Xie

unread,
Feb 20, 2014, 12:58:03 AM2/20/14
to Victor Kryukov, shiny-discuss
Unfortunately, that is expected -- sorting is locale dependent for
character strings. Characters are unlike numbers, which have definite
orders. See ?sort in R.

Regards,
Yihui
Reply all
Reply to author
Forward
0 new messages