Bra*_*wan 6 r shiny shiny-server shinydashboard
传统上,sliderInput函数是
sliderInput(inputId, label, min, max, value, step = NULL, round = FALSE, format = NULL,
locale = NULL, ticks = TRUE, animate = FALSE, width = NULL, sep = ",",
pre = NULL, post = NULL, timeFormat = NULL, timezone = NULL, dragRange = TRUE)
Run Code Online (Sandbox Code Playgroud)
如果我指定
sliderInput("range","range",min=-3,max=3,value=c(-1,1))
Run Code Online (Sandbox Code Playgroud)
它输入一个从-1到1的范围.但是,有一个函数采用参数格式为days_included = c(-2,-1,0,1,2).在这种情况下,如果我设置,我不能使这个功能工作
sliderInput("range","range",min=-3,max=3,value=c(-2,2))
Run Code Online (Sandbox Code Playgroud)
因为它与所需的格式不匹配.所以这是我的问题,无论如何要使这个功能起作用?我在sliderInput中尝试了"step"参数但是失败了.
您的滑块返回两个值,如果您想拥有介于两者之间的所有整数,则必须使用这些值和/:或seq函数创建一个序列。
所以基本上你需要 input$range[1]:input$range[2]
最小的例子:
library(shiny)
rm(ui) ; rm(server)
ui <- fluidPage(
br(),
sliderInput("range","range",min = -3, max = 3, value = c(-2, 2)),
div(verbatimTextOutput("out1"), style = "width: 300px;")
)
server <- function(input, output) {
output$out1 <- renderText({
# seq.int(from = input$range[1], to = input$range[2])
input$range[1]:input$range[2]
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1208 次 |
| 最近记录: |