I would like to know how do I solve the error:
Aesthetics must be either length 1 or the same as the data (437): x, y
I am trying to make a histogram using shiny R: I have created two widgets, and if the user chose "IL" as their choice, the x-axis would be all the counties in "IL" (this is what "x" variable is for later on)
output$hist <- renderPlot({
# Store x and y values to produce the chart
x <- chart_two_data$county[chart_two_data$state == input$x_var]
y <- chart_two_data[[input$y_var]]
title <- "Number of Population Race in county by State"
# Create ggplot hist
ggplot(data = chart_two_data) +
geom_bar(mapping = aes(x = x, y = y),
stat = "identity") +
ggtitle("Population Number Of Each Race Based On State")
})