lfiondella / SRT

Software Reliabilty Testing
5 stars 9 forks source link

Format datatables with formatRound function using magrittr package #82

Open arhik opened 8 years ago

arhik commented 8 years ago

library(DT) df <- data.frame( A = rpois(100, 1e4), B = runif(100), C = rpois(100, 1e3), D = rnorm(100), E = Sys.Date() + 1:100 ) datatable(df) %>% formatCurrency(c('A', 'C'), '€') %>% formatPercentage('B', 2) %>% formatRound('D', 3) %>% formatDate('E', 'toDateString')

arhik commented 8 years ago

This the best way to do it. I tried doing last but one week ago but no success. I was successful one way but I will loose reactivity. Its tough than i thought.

arhik commented 8 years ago

@bdavs Check this if you have a chance. Not sure if its related.

http://stackoverflow.com/questions/31318782/natural-sorting-in-shiny-dt-datatables-doesnt-work.

arhik commented 8 years ago

@bdavs if you observe the last comment in the above link its best to delegate this task to client browser. If it works then we will be done dealing with this issue. But we cannot avoid this plugin dependency again.

"@user1991825 Unfortunately this plug-in was not designed for the server-side processing mode. To implement natural sorting for server = TRUE may be a little involved, but you can file a feature request to github.com/rstudio/DT/issues anyway. I'll see if it is possible when I have got more time."

bdavs commented 8 years ago

The main problem is that there are strings in the datatable(NA). There are plugins that are available for DT to sort numbers when there are strings in the datatable. It does not require an aditional memory as the .js file needed can be included in the source code. http://datatables.net/plug-ins/sorting/