1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
library(shiny)
library(ggplot2)
library(dplyr)
library(shinyTime)
library(lubridate) #variable temps
route_fond_degre <- c(1:10)
vitesse_fond_noeuds <- c(2:11)
heure <- c("01:05:37","02:05:38","03:05:39","12:05:30","14:05:31","16:05:32","16:05:33","16:05:34","17:05:35","23:05:36")
df <- 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("24: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
plotOutput("graph1")
)
server <- function(input, output) {
date_filtre <- reactive({
mini <- as.character(input$periode[1])
maxi <- as.character(input$periode[2])
data_sel <- df %>% filter(heure > mini & heure < maxi)
return(data_sel)
})
#df_test <- df %>% filter(heure > "10:05:32") #ce cas fonctionnait avant le sliderinput
output$graph1 <- renderPlot({
g <- ggplot(date_filtre(), aes_string(x="heure", y = "route_fond_degre"))+
geom_point()
g
})
}
shinyApp(ui=ui, server=server) |
Partager