Page 1 of 1

Pls help out What five days of the year had the highest mean distance when leaving from JFK? Sort in descending order. T

Posted: Thu Jul 14, 2022 2:19 pm
by answerhappygod
Pls help out What five days of the year had the highest mean distance when leaving from JFK? Sort in descending order. The answer should be assigned to Q4 and appear like this:
Here is my code:
Q4 <- flights %>%
filter(origin == "JFK") %>%
group_by(month, day) %>%
summarise(mean_distance = format(round(mean(distance),2),2)) %>%
arrange(desc(mean_distance))%>%
head(5)
Please correct my code and input here so I can see the difference.
This should be the correct output
month day mean_distance
12 26 1342.40
12 23 1336.41
12 19 1335.62
12 30 1333.51
12 22 1332.73
Here is the output I was getting.
# A tibble: 5 × 3
# Groups: month [1]
month day mean_distance
<int> <int> <chr>
12 26 1342.4
12 23 1336.41
12 19 1335.62
12 30 1333.51
12 22 1332.73