I am trying to built a r shiny app with filtering based on date. but ggplot is not picking the x and y values and also there is number shown in place of date when i output the filtered data as a table.
data2$Deployment.Month<- as.Date(data2$Deployment.Month,format = "%d-%m-%Y")
min_date <- min(data2$Deployment.Month)
max_date <- max(data2$Deployment.Month)
data3 <- as.data.frame(data2)
data4<- na.omit(data3)
ui <- fluidPage(
sidebarLayout(
# Input(s)
sidebarPanel(
# Select variable for x-axis
selectInput(inputId = "x",
label = "Variable 1",
choices = c(choices),
selected = "Project.Id"),
# Select variable for y-axis
selectInput(inputId = "y",
label = "Variable 2",
choices = c(choices),
,
dateRangeInput(inputId = "date",
label = "Select dates:",
start = "2013-01-01",
end = "2017-12-31",
startview = "year",
min = as.Date(min_date), max = as.Date(max_date))),
mainPanel(plotOutput(outputId = "scatterplot"),tableOutput("table"))))
server<- function(input, output){
output$scatterplot <- renderPlot({req(input$date)
projects_selected_date <- data4 %>%filter(Deployment.Month >= input$date[1] & Deployment.Month <=input$date[2])
ggplot(projects_selected_date,aes_string(x=projects_selected_date$x,y=projects_selected_date$y),colour='red')+ geom_point()})
output$table <- renderTable({
projects_selected_date <- data4 %>% filter(Deployment.Month >= input$date[1] & Deployment.Month <= input$date[2])
projects_selected_date})}
# Create a Shiny app object
shinyApp(ui = ui, server = server)
it is showing error- error- geom_point requires the following missing aesthetics: x, y.