第一题
data_flights <- flights%>%inner_join(airlines)
data_flights <- data_flights[sample(nrow(flights),1000
0),]
第二题
if (is.character(data_flights$name)) data_flights$name <-
as.factor(data_flights$name)
第三题
data_flights%>%group_by(name)%>%summarize(count=n(),mdist
ance=mean(distance,na.rm=TRUE),mdep_delay=mean(dep_delay,
na.rm=TRUE))%>%arrange(desc(mdistance))
第四题
if (is.character(data_flights$month)) data_flights$month
<- as.factor(data_flights$month) )
data_flights%>%ggplot(data_flights,mapping=aes(x=month,y=
ldistance))+geom_boxplot()
第五题
monthly_data <- data_flights%>%group_by(year,month)%>%mut
ate(demean_dist=distance-mean(distance))%>%select(year,mo
nth,demean_dist)
> monthly_data
第七题
Ame <- data_flights%>%filter(str_detect(name,"America"))
> Ame
data_flights <- flights%>%inner_join(airlines)
data_flights <- data_flights[sample(nrow(flights),1000
0),]
第二题
if (is.character(data_flights$name)) data_flights$name <-
as.factor(data_flights$name)
第三题
data_flights%>%group_by(name)%>%summarize(count=n(),mdist
ance=mean(distance,na.rm=TRUE),mdep_delay=mean(dep_delay,
na.rm=TRUE))%>%arrange(desc(mdistance))
第四题
if (is.character(data_flights$month)) data_flights$month
<- as.factor(data_flights$month) )
data_flights%>%ggplot(data_flights,mapping=aes(x=month,y=
ldistance))+geom_boxplot()
第五题
monthly_data <- data_flights%>%group_by(year,month)%>%mut
ate(demean_dist=distance-mean(distance))%>%select(year,mo
nth,demean_dist)
> monthly_data
第七题
Ame <- data_flights%>%filter(str_detect(name,"America"))
> Ame