1
votes

I wanted to set dynamic minimum and maximum values for the slider based on the input value of a radio button. Now I was able to do this using renderUI option, I set my min and max values in the server.ui and values are set dynamically.

But when I put animation options inside the renderUI that does not work properly. In my ui.r I have following codes.

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")

And in my server.r I have set values as follows.

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
I seem to have the same problem here. Did you manage to find a solution/workaround for this problem since you posted your question?Simon Garnier

1 Answers

0
votes

try replacing your current slider function with this:

output$Slider<-renderUI({
  date_of_month<-as.numeric(format(as.Date(order$Date.Ordered), input$interval)) 
  sliderInput("date_range", "Date Range", min = 2,
              max = max(date_of_month), value = max(date_of_month)
              ,step = 1
              ,animate = animationOptions(loop = TRUE, interval = 5000))
})
  1. Use input$interval rather than interval to access the input value.
  2. Move the calculation of date_of_month inside the renderUI function so that it is reactive to changes in input$interval.