带有renderUI的R Shiny动画滑块

时间:2015-02-15 03:48:24

标签: r animation slider shiny

我想根据单选按钮的输入值设置滑块的动态最小值和最大值。现在我可以使用renderUI选项执行此操作,我在server.ui中设置了min和max值,并且动态设置了值。

但是当我将动画选项置于无法正常工作的renderUI中时。在我的ui.r中,我有以下代码。

radioButtons("interval", "Time Interval:", 
             c("Day of the week"="%u","Day of the month" = "%d", "Week of the year" = "%W", "Month of the year" = "%m","Quarter of the year"="quarter","year"="%y")) 
,uiOutput("Slider")

在我的server.r中,我设置了如下值。

order$date_of_month<-as.numeric(format(as.Date(order$Date.Ordered), interval)) 
output$Slider<-renderUI({
  sliderInput("date_range", "Date Range", min = 2,
              max = max(order$date_of_month), value = max(order$date_of_month)
              ,step = 1
              ,animate = animationOptions(loop = TRUE, interval = 5000))
})



radioButtons("interval", "Time Interval:", 
             c("Day of the week"="%u","Day of the month" = "%d", 
               "Week of the year" = "%W", "Month of the year" = "%m","Quarter of the year"="quarter","year"="%y")) 
,uiOutput("Slider")

1 个答案:

答案 0 :(得分:0)

尝试以此替换当前的滑块功能:

input$interval
  1. 使用interval而非date_of_month访问输入值。
  2. renderUI函数内部移动input$interval的计算,以便对{{1}}中的变化起反应。