Hello,
I'm experimenting with shiny dashboards for the first time and I'm trying to create a very basic dashboard. I created three user input features to be used within the sidebar which are all dateInputs. What I would like to do is use these three date inputs to filter my dataset and then create a bar graph which is grouped by the dates.
The issue I'm running into is the when I run my app and then input my date filters, my graph doesn't populate. I'm not sure why but I think its the way my data's date column is formatted. Additionally, is it possible to force the date calendar to not automatically pop-up whenever I go to input a date filter?
df<-data.frame(
Cat=c("A","B","C","A","B","C","A","B","C"),
Dates=c("092021","092021","092021","062021","062021","062021","092020","092020","092020"),
Amount=c(500,1000,400,750,900,500,600,300,200))
df$Dates<-as.yearmon(as.Date(anydate(df$Dates)))
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar( menuItem("Date Inputs",tabName = "dates",
dateInput("date1", "Date1:", startview = "month",format="M yyyy", autoclose = TRUE),
dateInput("date2", "Date2:", startview = "month",format="M yyyy", autoclose = TRUE),
dateInput("date3", "Date3:", startview = "month",format="M yyyy", autoclose = TRUE))),
dashboardBody(
mainPanel(plotOutput("Invplot")))
)
server <- function(input, output) {
output$Invplot<-renderPlot({
df%>%filter(Dates==as.yearmon(as.Date(anydate(input$date1))), Dates==as.yearmon(as.Date(anydate(input$date2))), Dates==as.yearmon(as.Date(anydate(input$date3))))%>%
group_by(Dates)%>%ggplot(aes(Dates,Amount),fill=Cat)+geom_bar()
})
}
shinyApp(ui, server)