R 闪亮的滑块从最大值到最小值

R 闪亮的滑块从最大值到最小值,r,slider,shiny,R,Slider,Shiny,是否可以制作一个按降序显示值的幻灯片(从左到右;例如5 4 3 2 1) 编辑2017-10-13:此函数现在在软件包中提供(使用不同的名称:sliderTimeput()) 您好,您可以这样编写自己的滑块函数(有点脏…): 还有一点:它也适用于字符向量: runApp( list( ui = fluidPage( sliderValues(inputId = "test", label = "", from = "g", to = "o", values = lette

是否可以制作一个按降序显示值的幻灯片(从左到右;例如5 4 3 2 1)


编辑2017-10-13:此函数现在在软件包中提供(使用不同的名称:
sliderTimeput()

您好,您可以这样编写自己的滑块函数(有点脏…):

还有一点:它也适用于字符向量:

runApp(
  list(
    ui = fluidPage(
      sliderValues(inputId = "test", label = "", from = "g", to = "o", values = letters),
      verbatimTextOutput(outputId = "slidervalue")
    ),
    server = function(input,output) {
      output$slidervalue <- renderPrint({
        # Careful ! : input$test isn't the expected value !!!
        letters[input$test + 1]
      })
    }
  )
)
runApp(
名单(
ui=fluidPage(
sliderValues(inputId=“test”,label=”,from=“g”,to=“o”,值=字母),
逐字输出(outputId=“slidervalue”)
),
服务器=功能(输入、输出){

输出$slidervalue伟大的解决方案@Victorp
sliderValues <- function (inputId, label, values, from, to = NULL, width = NULL) {
        sliderProps <- shiny:::dropNulls(list(class = "js-range-slider", 
                                      id = inputId,  
                                      `data-type` = if (!is.null(to)) "double",
                                      `data-from` = which(values == from) - 1,
                                      `data-to` = if (!is.null(to)) which(values == to) - 1,
                                      `data-grid` = TRUE,
                                      `data-values` = paste(values, collapse = ", ")
                                      ))
        sliderProps <- lapply(sliderProps, function(x) {
          if (identical(x, TRUE)) 
            "true"
          else if (identical(x, FALSE)) 
            "false"
          else x
        })
        sliderTag <- div(class = "form-group shiny-input-container", 
                         style = if (!is.null(width)) 
                           paste0("width: ", validateCssUnit(width), ";"), 
                         if (!is.null(label)) 
                           shiny:::controlLabel(inputId, label), do.call(tags$input, 
                                                                 sliderProps))
        dep <- list(htmltools::htmlDependency("ionrangeslider", "2.0.12", c(href = "shared/ionrangeslider"), 
                                   script = "js/ion.rangeSlider.min.js",
                                   stylesheet = c("css/ion.rangeSlider.css",
                                                  "css/ion.rangeSlider.skinShiny.css")))
        htmltools::attachDependencies(sliderTag, dep)
      }
library("shiny")
runApp(
  list(
    ui = fluidPage(
      # you have to pass the values you want in the slider directly to th function
      sliderValues(inputId = "test", label = "", from = 5, values = 5:1),
      verbatimTextOutput(outputId = "slidervalue")
    ),
    server = function(input,output) {
      output$slidervalue <- renderPrint({
        # Careful ! : input$test isn't the expected value !!!
        (5:1)[input$test + 1]
      })
    }
  )
)
runApp(
  list(
    ui = fluidPage(
      sliderValues(inputId = "test", label = "", from = "g", to = "o", values = letters),
      verbatimTextOutput(outputId = "slidervalue")
    ),
    server = function(input,output) {
      output$slidervalue <- renderPrint({
        # Careful ! : input$test isn't the expected value !!!
        letters[input$test + 1]
      })
    }
  )
)