将逗号添加到闪亮的renderDataTable中的每个数字 [英] Add commas to every number in shiny renderDataTable

查看:105
本文介绍了将逗号添加到闪亮的renderDataTable中的每个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据库中以逗号分隔显示大量数字。为了做到这一点,我该如何在Shiny应用程序的renderDataTable函数中包含格式货币子句?

I would like to display large numbers with comma separation in a datable. How would I include the format currency clause in the renderDataTable function in a Shiny app in order to do this?

这篇文章显示了如何将其添加到常规DT中,但我正在将数据表输入用户界面。我没有将货币视为选项之一。

This post shows how to do add it to a regular DT, but I'm feeding the datatable into the UI. I don't see currency as one of the options.

output$dummy_data_table <- DT::renderDataTable(
    data.frame(A=c(1000000.51,5000.33, 2500, 251), B=c(0.565,0.794, .685, .456)),
    extensions = 'Buttons',
    server=FALSE,
    options = list(
      pageLength = 50,
      scrollX=TRUE,
      dom = 'T<"clear">lBfrtip',
    )  # close options
  ) # close renderDataTable


推荐答案

关注我的评论-

shinyApp(
  ui = fluidPage(
    DTOutput("dummy_data_table")
  ),
  server = function(input, output) {
    output$dummy_data_table <- DT::renderDataTable(
      data.frame(A=c(1000000.51,5000.33, 2500, 251), B=c(0.565,0.794, .685, .456)) %>%
        datatable(extensions = 'Buttons',
          options = list(
            pageLength = 50,
            scrollX=TRUE,
            dom = 'T<"clear">lBfrtip'
          )
        ) %>%
        formatCurrency(1:2, currency = "", interval = 3, mark = ",")
    ) # close renderDataTable
  }
)

这篇关于将逗号添加到闪亮的renderDataTable中的每个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆