【问题标题】:How to set recently 3 days in dateRangeInput of shiny?如何在闪亮的 dateRangeInput 中设置最近 3 天?
【发布时间】:2014-10-16 03:42:40
【问题描述】:

我想在 dateRangeInput 中显示最近 3 天的默认值。现在 Sys.Date() 设置开始、结束和最大值。这是我的 ui.R 和 server.R

ui.R

shinyUI(pageWithSidebar(

    # Application title
    headerPanel('dateRangeInput'),

    # Sidebar with a slider input for number of observations
    sidebarPanel(
        wellPanel(
            dateRangeInput('days', 'Select a date range:', 
                start = Sys.Date() - 3,
                end = Sys.Date(), 
                max = Sys.Date()))
    ),
    mainPanel()
))

服务器.R

shinyServer(function(input, output, session) 
{

})

但是,当日期更改时,日期会冻结在 Shiny App 的启动日期。见截图。

如何根据当前日期动态更改开始、结束和最大值?感谢您的任何建议。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    我在 server.R 中添加了一个观察。不确定这是最好的解决方案。

    服务器.R

    shinyServer(function(input, output, session) 
    {
    
        observe({
            updateDateRangeInput(session, "days",
                start = Sys.Date() - 3,
                end = Sys.Date(), 
                max = Sys.Date())
        })
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-16
      • 2021-01-04
      • 2020-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多