闪亮:无法向我的值框添加颜色、图标或副标题

Shiny: can't add color, icon or subtitle to my valuebox

我使用 shiny 构建了我的第一个仪表板,我想添加一些值框,但是当我这样做时,值框出现时没有颜色、副标题或图标。

我不知道错误是什么。请帮助并提前致谢。

这是我写的代码:

library(shiny)
library(shinydashboard)
library(flexdashboard)
library(readxl)
Base_Ferias <- read_excel("C:/Users/tomas/Desktop/R/Apps/Seguimiento_ferias/Base_Avance_Ferias.xlsx")
Base_Ferias$T_respuesta <- as.numeric(Base_Ferias$T_respuesta)



ui <-dashboardPage(skin = "red",
                   dashboardHeader(title = "My Dashboard", titleWidth = 450),
                   dashboardSidebar(selectInput("actividad", "Select", 
                                                choices = Base_Ferias$Actividad)),
                   dashboardBody(
                     box(flexdashboard::gaugeOutput("chart"),width=200,
                                  title="Percentage"),
                     box(valueBoxOutput("value1"), height = "100px", width = 3)

                     )
                   )



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

  output$chart <- flexdashboard::renderGauge({
    x <- Base_Ferias[Base_Ferias$Actividad==input$actividad,]
    y <- x$T_respuesta
    gauge(y, min = 0, max = 100, symbol = '%')
    })

  output$value1 <- renderValueBox({
    valueBox(
      paste0(25,"%"), "subtitle",icon("stats",lib='glyphicon'),
             color = "purple")
  })
})

shinyApp(ui = ui, server = server)

附加 flexdashboard 最后一个与 shinydashboard 同名的掩码函数。使用 shinydashboard 中的 valueBox 代替:

library(shiny)
library(shinydashboard)
#> 
#> Attaching package: 'shinydashboard'
#> The following object is masked from 'package:graphics':
#> 
#>     box

ui <-dashboardPage(skin = "red",
                   dashboardHeader(title = "My Dashboard", titleWidth = 450),
                   dashboardSidebar(selectInput("actividad", "Select", 
                                                choices = c("one", "two"))),
                   dashboardBody(
                     box(flexdashboard::gaugeOutput("chart"),width=200,
                         title="Percentage"),
                     box(valueBoxOutput(outputId = "value1"))

                   )
)



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

  output$chart <- flexdashboard::renderGauge({
    x <- 1
    y <- 10
    flexdashboard::gauge(y, min = 0, max = 100, symbol = '%')
  })

  output$value1 <- renderValueBox({
    valueBox(
      paste0(25,"%"), "subtitle",icon("stats",lib='glyphicon'),
      color = "purple")
    })
})

shinyApp(ui = ui, server = server)
#> 
#> Listening on http://127.0.0.1:5809

reprex package (v0.3.0)

于 2020-03-04 创建