如何在R中输入6个小时的步骤

时间:2019-06-27 04:37:48

标签: r shiny

library(shiny)

# ui.R

ui <- shinyUI(fluidPage(
  title = 'Initial run of time range update breaks sliderInput',
  fluidRow(
    column(width = 100, 
           sliderInput("timeRange", label = "Time range",
                       min = as.POSIXct("2011-06-04 12:00:00"),
                       max = as.POSIXct("2011-08-10 14:00:00"),
                       value = c(as.POSIXct("2011-06-04 12:00:00"),
                                 as.POSIXct("2011-08-10 14:00:00"))),
           actionButton("update", "Update range")

    )
  )))

server <- shinyServer(function(input, output, session) {
  output$from <- renderText(input$timeRange[1]);
  output$to <- renderText(input$timeRange[2]);
  observe({
    input$update;
    updateSliderInput(session, "timeRange", value = 
                        c(as.POSIXct("2011-06-14 
          12:00:00"), as.POSIXct("2011-08-01 14:00:00")));
  })
})

runApp(list(ui = ui,server = server))

上面是代码。我想制作滑块,使每一步都会增加或减少6个小时。

我应该将sliderInput函数的“ step”参数设置为什么?

1 个答案:

答案 0 :(得分:1)

我还没有测试过,但是step for a POSIXt object只需几秒钟。

所以我想6小时= 6 * 60 * 60 = 21600吗?