Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在shinydashboard中以背景色显示框中的数据表_R_Shiny_Shinydashboard - Fatal编程技术网

如何在shinydashboard中以背景色显示框中的数据表

如何在shinydashboard中以背景色显示框中的数据表,r,shiny,shinydashboard,R,Shiny,Shinydashboard,我想把我的数据表放在我闪亮的仪表板中的一个框中。我将方框背景颜色设置为绿色。但是,我发现我的数据表内容没有显示在框中。有人知道如何解决这个问题吗?谢谢 library(shiny) library(shinydashboard) ui <- dashboardPage( dashboardHeader(title = "example"), dashboardSidebar(), dashboardBody( box(width=6, backg

我想把我的数据表放在我闪亮的仪表板中的一个框中。我将方框背景颜色设置为绿色。但是,我发现我的数据表内容没有显示在框中。有人知道如何解决这个问题吗?谢谢

library(shiny)
library(shinydashboard)


ui <- dashboardPage(
    dashboardHeader(title = "example"),
    dashboardSidebar(),
    dashboardBody(
        box(width=6, background = 'green',
            DT::dataTableOutput('table') 
        )
    )
)

server <- function(input, output, session) {

    output$table <- DT::renderDataTable({
        DT::datatable(iris)
    })
}    


shinyApp(ui, server)

这只是字体颜色的问题:

library(shiny)
library(shinydashboard)


ui <- dashboardPage(
  dashboardHeader(title = "example"),
  dashboardSidebar(),
  dashboardBody(
    box(width=6, background = 'green',
        DT::dataTableOutput('table') 
    )
  )
)

server <- function(input, output, session) {

  output$table <- DT::renderDataTable({
    df <- iris
    DT::datatable(df) %>% 
      # rowid is a column as well, therefore zero to nrow()
      DT::formatStyle(0:nrow(df), color = "black")
  })
}    


shinyApp(ui, server)

您的代码适用于我,但框的宽度太小。我只能在单击行时才能看到表内容。你没有看到任何问题?