14

下面是我写的代码。我不能formattable在我的闪亮中使用。formattable有助于格式化表格并改善可视化效果。

library("shinydashboard")
library("shiny")
library("formattable")

body <- dashboardBody(
  fluidRow(
    column(width = 12,
           box(tableOutput(formattable(test.table, list())))
           )
    )
  )

ui <- dashboardPage(
  dashboardHeader(title = "Column layout"),
  dashboardSidebar(),
  body
)

server <- function(input, output) {

  test.table <- data.frame(lapply(1:8, function(x) {1:10}))

    output$table <- renderTable({test.table})
}
shinyApp(ui = ui, server = server)
4

1 回答 1

30

你必须使用 renderFormattable、formattableOutput 和 formattable,这三个都可以工作

library("shinydashboard")
library("shiny")
library("formattable")

body <- dashboardBody(
 fluidRow(
   column(width = 12,
        box(formattableOutput("table"))
   )
 )
)

ui <- dashboardPage(
    dashboardHeader(title = "Column layout"),
    dashboardSidebar(),
    body
 )

 server <- function(input, output) {

    test.table <- data.frame(lapply(1:8, function(x) {1:10}))

    output$table <- renderFormattable({formattable(test.table, list())})
}
shinyApp(ui = ui, server = server)
于 2016-01-15T14:43:16.943 回答