0

Friends of stackoverflow, Maybe I am just combining too many variables..or maybe not, I do not know. But it would be fantastic to get a sanity check!

made in flexdashboard

I have the following inputs:

dateRangeInput(“date”, “Choose a date range:”, 
start = min(mydata$Date),
end = max (mydata$Date),
startview = “year”

selectInput(“cntry”, “Choose a Country:”,
choices = c(“”, mydata$Country), multiple = TRUE)

selectInput (“city”, “Choose a City:”,
choices =c(“”, mydata$City),multiple = TRUE)

selectInput (“animal”, “Choose an animal:”,
choices = c(“”, mydata$Animal) multiple = TRUE)

I then create two outputs: a datatable and a plot: (as seen here)

renderDataTable({

    cntry_sel <- if (nchar(input$cntry)==0) unique(as.vector(mydata$Country)) else input$cntry

city_sel <- if (nchar(input$city)==0) unique(as.vector(mydata$City)) else input$city

animal_sel <- if (nchar(input$animal)==0) unique(as.vector(mydata$Animal)) else input$animal

filter(mydata, Country %in cntry_sel, City %in% city_sel, Animal %in% animal_sel)
})

This works great for filtering the data in a datatable. However, I cannot get the plot to render correctly:

First issue: The plot renders, but will give me the entire date range not the range selected:

For e.g: , dateRangeInput = start: 2017-01-01, end: 2017-12-31, but, the rendered plot will display all dates for the filtered data (2015-2018).

This is made more curious by the dact that the other inputs, when changed, will update the plot.

For example, [input$cntry = Canada, input$animal= Bear] will render a plot of that selected data and updates if I change input$cntry = Mexico and/or input$animal = Donkey.

However, the year input will not. Any ideas? The render output is:

renderPlotly({

data<-mydata[,1:5] ##1=Date, 2=Count...
data$Country<-input$country
data$City<-input$city
data$Animal<-input$animal

ggplot(data,
aes(x=Date, y= Country, Fill= Country, Weight = Count)+
geom_bar

})
OctoCatKnows
  • 399
  • 3
  • 17

0 Answers0