I'm trying to run this code but it keeps saying
Error: Aesthetics must be either length 1 or the same as the data (5): y
and I have no idea why. I have looked at other questions with similar errors but I still don't get it:
flights = read.csv("http://www.maths.usyd.edu.au/u/UG/JM/DATA1001/r/current/projects/2020data/flights.csv")
library(ggplot2)
library(dplyr)
library(plotly)
newdata = subset(flights, Year >= 2010)
average_flights = newdata %>%
filter(Year >= "2010" & Year <= "2021")%>%
filter(Month_num >= 1 &Month_num !=12) %>%
group_by(Month_num)%>%
summarise(sum_flights = sum(All_Flights))
myflights2 = flights %>%
filter(Year >= "2010" & Year <= "2021") %>%
group_by(Airline) %>%
count() %>%
arrange(desc(n)) %>%
head(5) %>%
ggplot(myflights2, mapping = aes(x = Airline, y = average_flights, fill(In_Out))) +
geom_bar() +
ggtitle("Average Number of Flights Each Month Per Airline")
ggplotly(myflights2)
