Render large numbers as with thousands separators in a shiny DataTable by default.
The documentation reads (to me) like it should alr
I know this is quite an old post, however was struggling with this today too so thought that someone else may get value from this solution.
Since the question was asked the DT package was released by RStudio (Github or CRAN).
At first glance it isn't too obvious how to format numbers as their isn't a corresponding formatNumber function like their is formatCurrency. The way around it is to use the formatCurrency and just set the currency parameter to nothing. Example below.
library(shiny)
library(DT)
runApp(
list(ui = fluidPage(
DT::dataTableOutput("mytable")
),
server = function(input, output, session) {
output$mytable <- DT::renderDataTable(
DT::datatable(iris*1000,
options = list(pageLength = 50,
columnDefs = list(list(className = 'dt-left',
targets = 0:4)))) %>%
formatCurrency(1:4, '')
)
}
)
)