-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dates.qmd
48 lines (40 loc) · 1.08 KB
/
Dates.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
```{r}
library(tidyverse)
flights <- nycflights13::flights
```
```{r}
flightssubset <- flights %>%
select(year:sched_dep_time) %>%
slice(1:3, .by = month) %>%
arrange(month)
```
```{r}
flightssubset %>%
mutate(date = make_date(year = year, month = month, day = day),
day_of_year = yday(date),
day_of_month = mday(date),
day_of_week = wday(date),
week_of_year = week(date)) %>%
select(-c(year, month, day))
```
# Laver heatmap over afgange
```{r}
counts <- flights %>%
mutate(date = make_date(year = year, month = month, day = day),
day_of_year = yday(date),
day_of_month = mday(date),
day_of_week = wday(date),
week_of_year = week(date)) %>%
count(week_of_year, day_of_week)
counts %>% ggplot(aes(x = week_of_year, y = day_of_week, fill = n)) +
geom_tile(col = 'white') +
theme_minimal(base_line_size = 16) +
coord_equal() +
scale_fill_gradient(high = 'green', low = 'red') +
labs(
y = element_blank(),
x = "Week",
fill = "Flights",
title = "Number of flights in NYC in 2013"
)
```