“纽约市有多少个机场?哪个机场的航班最多?使用条形图显示每个机场的航班数量。”
如何显示纽约市的所有机场 我试过这段代码但是没有工作只显示一个变量 我试图通过过滤功能使用机场数据的航班数据但是没有用 这些我的代码
filter(airports,tzone == "America/New_York" ,dst == "A" )
filter(airports, dst == "A" )
library(nycflights13)
library(tidyverse)
?airports
filter(airports, faa == "NYC", tzone == "America/New_York" )
filter(flights, dest == "NYC")
flights <- flights %>%
mutate(dep_type = ifelse(dep_delay < 5, "on time", "delayed"))
qplot(x = origin, fill = dep_type, data = flights, geom = "bar")
答案 0 :(得分:1)
通过使用包含'New_York`的条件tzone
进行过滤,可以找到纽约机场的数量。
airports %>%
filter(grepl("New_York", tzone)) %>% summarise(Number_of_Airport_NYC = n())
#Number_of_Airport_NYC
# <int>
#1 519
最大航班数量可以是:
flights %>% group_by(dest) %>%
summarise(FlightCount = n()) %>%
filter(FlightCount == max(FlightCount))
# dest FlightCount
# <chr> <int>
#1 ORD 17283
每个机场的航班数量可以是:
flights %>% group_by(dest) %>%
summarise(FlightCount = n())
# dest FlightCount
# <chr> <int>
#1 ABQ 254
#2 ACK 265
#3 ALB 439
# ... with 102 more rows