Hello,
I am trying to make this shiny app to get the date from the selector (ui) and pass it to the r code (server) but it is not working and outputting an error.
It seems the problem is getting input$date into the filter
correctly.For instance if I type filter(DATE>='2020-05-01')
it works.
Bellow is is a snippet:
ui <- fluidRow(box(width = 4,dateInput("date",format = "dd/mm/yyyy",language = "pt-BR", label = h3("DATE"),value = Sys.Date()))
),
fluidRow(box(width = 12,height = 10,plotOutput(outputId = "Plot"))
))))
server <- function(input,output){
output$Plot <- renderPlot({
data %>% filter(DATE>=input$date) %>% filter(!wday(DATE) %in% c(1,7)) %>% mutate(sdavg=rollmeanr(SALES,k=5,fill=NA)) %>% ggplot(.,aes(x=DATE)) + geom_line(aes(y=SALES,color="#003366"))+ geom_line(aes(y=sdavg,color="#ff3300"))+ theme(axis.text.x = element_text(angle = 60),legend.position = "none")
})
}
I get the error: Aesthetics must be either length 1 or the same as the data (1): y, x when I use `filter(PEDDTEMIS>=input$date)`
What is the correct way to pass `input$date` to the code ?
Thanks