首页 > 其他 > 详细

R(week 15)

时间:2021-06-07 20:21:24      阅读:37      评论:0      收藏:0      [点我收藏+]
library(tidyverse)
install.packages("nycflights13")
library(nycflights13)
library(lubridate)

dailyFlight <- flights %>%
  mutate(date = make_date(year, month, day)) %>%
  group_by(date) %>%
  summarise(n = n())

dailyFlight2 <- dailyFlight %>%
  mutate(weekDay = wday(date, label = TRUE, locale = "English"))

View(dailyFlight2)

ggplot (dailyFlight2, aes(weekDay, n)) + geom_boxplot()

dailyFlight2$weekDay <- as.factor(dailyFlight2$weekDay)
ggplot(dailyFlight2, aes(x = date, y = n, col = weekDay)) + 
  geom_point() +
  geom_line() +
  scale_x_date(NULL, date_breaks = "1 month", 
               date_labels = "%b")

delayFlights <- flights %>%
  group_by(origin, dest) %>%
  summarise(count = n(), dist = mean(distance, na.rm = TRUE), 
            delay = mean(arr_delay, na.rm = TRUE)) %>%
  filter(count > 20)

ggplot(data = delayFlights) + geom_point(mapping = aes(x = dist, y = delay)) +
  geom_smooth(mapping = aes(x = dist , y = delay))

  

R(week 15)

原文:https://www.cnblogs.com/sineagle/p/14859932.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!