Valuebox未显示 - 闪亮的仪表板

时间:2018-05-11 11:07:49

标签: r shiny shinydashboard

我想使用flexdashboard包在我闪亮的仪表板中显示值框。请检查我的代码,没有显示值框。请帮我解决这个问题。

UI代码

library(shiny)
library(shinydashboard)
library(flexdashboard)

ui <- dashboardPage(skin = "black",
                    dashboardHeader(title = "test"),

                    dashboardSidebar(
                      sidebarMenu()),

                    dashboardBody(
                                fluidRow(
                                  valueBoxOutput("vbox1", width = 2),
                                  valueBoxOutput("vbox2", width = 2),
                                  valueBoxOutput("vbox3", width = 2),
                                  valueBoxOutput("vbox4", width = 2),
                                  valueBoxOutput("vbox5", width = 2),
                                  valueBoxOutput("vbox6", width = 2))))

服务器代码

server <- function(input, output) {

  #valuebox
  output$vbox1 <- renderValueBox({
    d <- 10
    valueBox( d, caption = "Coss")
  })

  output$vbox2 <- renderValueBox({ 
    d <- 42
    valueBox( d,"Ccy")
  })

  output$vbox3 <- renderValueBox({ 
    d <- 75
    valueBox( d,"Cty")})

  output$vbox4 <- renderValueBox({ 
    d <- 21
    valueBox( d,"Dup")})

  output$vbox5 <- renderValueBox({ 
    d <- 34
    valueBox( d,"Inte")})

  output$vbox6 <- renderValueBox({ 
    d <- 56
    valueBox( d,"Acd")})

  }

shinyApp(ui, server)

enter image description here

我只获取文本而不是值框。

由于 巴拉吉

2 个答案:

答案 0 :(得分:2)

flexdashboard程序包掩盖了Shinydashboard程序包的valueBoxOutput()函数。因此,要解决此问题,您应该使用shinydashboard::valueBoxOutput而不是valueBoxOutput

答案 1 :(得分:2)

a.lay几乎是正确的。 您还需要服务器功能的名称空间...

shinydashboard::valueBoxOutput('valueBoxA')

 output$valueBoxA <- shinydashboard::renderValueBox({
    shinydashboard::valueBox(
      'Default',
      x
    )
  })
相关问题