我的名字叫請輸入你的名字, 我的學號是請輸入你的學號.
flights %>% head
輸出程式碼(echo=TRUE),但文字產出先隱藏不輸出(results=“hide”)
flights %>% summarise_if(
is.numeric,
funs(
mean=mean(.,na.rm=TRUE),
sd=sd(.,na.rm=TRUE))) -> summary.stat
summary.stat %>% select(dep_delay_mean) %>% kable
本研究使用2013年美國機場起降資料,我們發現平均機場延遲出發時間為12.6390703分鐘。
| 航空公司 | 平均出發延遲 |
|---|---|
| EV | 19.95539 |
| F9 | 20.21554 |
| FL | 18.72607 |
| WN | 17.71174 |
| YV | 18.99633 |
| dep_delay_mean |
|---|
| 12.63907 |
hist(flights$dep_delay,
xlab="分鐘",
ylab="次數",
family="wqy-microhei")
出發延遲分配圖
使用kableExtra::kable_styling
library(kableExtra)
summary.stat.eachcarrier %>%
select(carrier,dep_delay_mean) %>%
top_n(5,dep_delay_mean) %>%
rename(航空公司=carrier,平均出發延遲=dep_delay_mean) %>%
kable(caption = "出發延遲前5名","html") %>%
kable_styling(bootstrap_options = "striped", full_width = F)
| 航空公司 | 平均出發延遲 |
|---|---|
| EV | 19.95539 |
| F9 | 20.21554 |
| FL | 18.72607 |
| WN | 17.71174 |
| YV | 18.99633 |