Link between sliderinput with hours, reactive and a plot

Hi everyone,
I don't succeed to have a link between a sliderInput with hours and a reactive in order to change the hour range in my plot... can somebody help me ? thanks a lot :slight_smile:

library(lubridate) #variable temps

route_fond_degre <- c(1:10)
vitesse_fond_noeuds <- c(2:11)
heure <- c("01:05:30","01:05:31","01:05:32","01:05:33","01:05:34","01:05:35","01:05:36",
#pas sur que cela s'écrive comme ca mais si je fais class(heure) j'ai hms
df_test <- data.frame(heure,  route_fond_degre, vitesse_fond_noeuds)

ui <- fluidPage(

             sliderInput(inputId = "periode",
                         label = "Période",
                         min = as.POSIXct("10:00:00",format = "%H:%M:%S"),
                         max = as.POSIXct("23:00:00",format = "%H:%M:%S"),
                         value = c(as.POSIXct("10:00:00",format = "%H:%M:%S"), as.POSIXct("23:59:59",format = "%H:%M:%S")),
                         timeFormat = "%H:%M:%S"),
             #le slider s'affiche bien mais pas de lien avec le plot


server <- function(input, output) {

    date_filtre <- reactive({

      mini <- as.POSIXct(input$periode[1])
      maxi <- as.POSIXct(input$periode[2])

      #df_test <- df_test %>% filter(heure > hms("10:00:00")) -> ce cas fonctionnait avant le sliderinput

      data_sel <- df_test %>% filter(heure > mini & heure < maxi)

    output$graph1 <- renderPlot({

      g <- ggplot(date_filtre(), aes_string(x="heure", y = "route_fond_degre"))+
      #j'ai mis un aes_string car je fais aussi changer le y en selectInput aussi avec choices = names(df_test)



shinyApp(ui=ui, server=server)

heure in df_test would be a factor or character vector the way you have it above

df_test <- data.frame(heure=hms(heure),  route_fond_degre, vitesse_fond_noeuds)

thanks, but it doesn't change anything...

I have found the pb :
mini <- strftime(input$periode[1], "%R")
maxi <- strftime(input$periode[2], "%R")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.