我有一个在我的 Shiny 应用程序中完美显示的 DataTable,除了千位分隔符,它根本不显示。我认为默认情况下它会使用逗号,但是当它没有显示时,我尝试使用 oLanguage sInfoThousands 来指定它。我的另一个 oLanguage 规范 sInfo 正在工作,所以我试图弄清楚为什么根本没有显示千位分隔符。这看起来像是数据类型问题还是我如何指定它的问题?前两列是两个表中的字符串,其余的是整数(在数据框中它们是双精度数),它们正在适当地排序。
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=","
)
)
})
})
感谢您的帮助,如果我应该提供更多信息,请告诉我。(发布的第一个问题,如果我违反了任何规则,请见谅!)
编辑(使用 mtcars--我将 mpg 乘以它应该需要千位分隔符):
#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"))
)
)
))
如何让逗号出现在 mpg 列中但仍将其排序为数字?我还没有发布图片的声誉,但这里是我所看到的屏幕截图的链接(第一列没有千位分隔符):