I have a DataTable that is displaying perfectly in my Shiny application except for the thousands separator, which is not displaying at all. I figured it would use a comma by default, but when it was not showing I tried to specify it using oLanguage sInfoThousands. My other oLanguage specification sInfo is working, so I am trying to figure out why no thousands separator is showing at all. Does this seem like a data type issue or an issue with how I've specified it? The first two columns are strings in both tables, and the rest are integers (in the dataframe they are doubles) which are sorting appropriately.
shinyServer(function(input, output, session){
tab1_final<-read.csv("/home/bdk/tracker/tab1_final.csv")
tab2_final<-read.csv("/home/bdk/tracker/tab2_final.csv")
mydata <- reactive({
switch(input$dataset, FY = data.table(tab2_final),
Q = data.table(tab1_final)
)
})
output$mytable <- renderChart2({
dTable(mydata(),
sPaginationType = 'full_numbers',
aLengthMenu = list(c(10, 25, 50, 100, -1),c(10, 25, 50, 100, "All")),
oLanguage = list(sInfo="Showing _START_ to _END_ of _TOTAL_ entries. All numbers shown in US Dollars.",
sInfoThousands=","
)
)
})
})
Thanks for the help, and let me know if I should provide any more info. (first question posted, so sorry if I've violated any rules!)
Edit (with mtcars--I multplied mpg so that it should require a thousands separator):
#server.R
require(rCharts)
shinyServer(function(input, output, session){
mtcars$mpg<-mtcars$mpg*1000.3
mydata <- reactive({
switch(input$dataset, By_Fiscal_Year = data.table(mtcars),
By_Quarter = data.table(mtcars)
)
})
output$mytable <- renderChart2({
dTable(data.table(mydata()),
sPaginationType = 'full_numbers',
aLengthMenu = list(c(10, 25, 50, 100, -1),c(10, 25, 50, 100, "All")),
oLanguage = list(sInfoThousands=",")
)
})
})
#ui.R
require(shiny)
require(shinyIncubator)
require(rCharts)
options(RCHART_LIB = 'polycharts')
shinyUI(pageWithSidebar(
headerPanel(list('Test DataTables Comma')),
sidebarPanel(
selectInput('dataset', 'Choose Current Quarter or Entire FY',
c('By_Fiscal_Year', 'By_Quarter')
)
),
mainPanel(
tabsetPanel(id ="tab1",
tabPanel("Table", chartOutput("mytable", "datatables"))
)
)
))
How do I get a comma to appear in the mpg column yet still have it sort as a number? I don't have the reputation yet to post an image, but here is a link to a screenshot of what I am seeing (first column has no thousands separator):