R光泽仪表图

R光泽仪表图,r,shiny,gauge,flexdashboard,R,Shiny,Gauge,Flexdashboard,有人能帮我在R Shining中绘制一个量表吗?我不需要它是动态的,但要有一个KPI,我用一个值来指定它,并在运行应用程序时显示它。它应该是红色的,从0到0.3,黄色的从0.3到0.5,绿色的从0.5到1。flexdashboard提供了这样一个量表: library(shiny) library(flexdashboard) ui <- fluidPage( numericInput("value", label = "Select value", min = 0, max = 1

有人能帮我在R Shining中绘制一个量表吗?我不需要它是动态的,但要有一个KPI,我用一个值来指定它,并在运行应用程序时显示它。它应该是红色的,从0到0.3,黄色的从0.3到0.5,绿色的从0.5到1。flexdashboard提供了这样一个量表:

library(shiny)
library(flexdashboard)

ui <- fluidPage(
  numericInput("value", label = "Select value", min = 0, max = 1, value = 0.5, step = 0.1),
  gaugeOutput("gauge")
)

server <- function(input, output) {

  output$gauge = renderGauge({
    gauge(input$value, 
          min = 0, 
          max = 1, 
          sectors = gaugeSectors(success = c(0.5, 1), 
                                 warning = c(0.3, 0.5),
                                 danger = c(0, 0.3)))
  })
}

shinyApp(ui = ui, server = server)
库(闪亮)
库(flexdashboard)

ui您还可以使用
C3

#devtools::install_github("FrissAnalytics/shinyJsTutorials/widgets/C3")
library(C3)
library(shiny)

runApp(list(
  ui = bootstrapPage(
    # example use of the automatically generated output function
    column(6,C3GaugeOutput("gauge1"))
  ),
  server = function(input, output) {

    # reactive that generates a random value for the gauge
    value = reactive({
      invalidateLater(1000)
      round(runif(1,0,100),2)
    })

    # example use of the automatically generated render function
    output$gauge1 <- renderC3Gauge({ 
      # C3Gauge widget
      C3Gauge(value())
    })
  }
))
#devtools::安装_github(“frisanalytics/shinyJsTutorials/widgets/C3”)
图书馆(C3)
图书馆(闪亮)
runApp(列表(
ui=引导(
#自动生成的输出函数的示例使用
柱(6,C3GaugeOutput(“gauge1”))
),
服务器=功能(输入、输出){
#为仪表生成随机值的无功
值=无功({
失效发生器(1000)
圆形(runif(1,0100),2)
})
#自动生成的渲染函数的示例使用
输出$gauge1