Load the Libraries
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 1.0.1
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(nycflights13)
library(RColorBrewer)
flights <- flights
flights2 <- flights %>%
filter(month == 1)
Jan <- filter(flights, month == 1)
flights_M <- flights %>%
mutate(month)
flights %>%
filter(month == 6 | month == 7 | month == 8) %>%
ggplot(aes(x = arr_delay, fill = month)) +
ggtitle("Monthly Arrival Delay Times for June") +
xlab("Monthly Delay") +
ylab("Frequency") +
geom_bar()+
scale_alpha_continuous()
## Warning: Removed 2871 rows containing non-finite values (`stat_count()`).
## Warning: The following aesthetics were dropped during statistical transformation: fill
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
flights %>%
filter(month == 7) %>%
ggplot(aes(x = arr_delay, fill = month)) +
ggtitle("Monthly Arrival Delay Times for July") +
xlab("Monthly Delay") +
ylab("Frequency") +
geom_bar()+
scale_alpha_continuous()
## Warning: Removed 1132 rows containing non-finite values (`stat_count()`).
flights %>%
filter(month == 8) %>%
ggplot(aes(x = arr_delay, fill = month)) +
ggtitle("Monthly Arrival Delay Times for August") +
xlab("Monthly Delay") +
ylab("Frequency") +
geom_bar()+
scale_alpha_continuous()
## Warning: Removed 571 rows containing non-finite values (`stat_count()`).
flights <- flights
flights2 <- flights %>%
filter(month == 1)
Jan <- filter(flights, month == 1)
flights_M <- flights %>%
mutate(month)
flights %>%
filter(month == 6 | month == 7 | month == 8) %>%
ggplot(aes(x = arr_delay, group=month, color = as.character(month))) +
ggtitle("Monthly Arrival Delay Times for August") +
xlab("Monthly Delay") +
ylab("Frequency") +
geom_bar()+
scale_alpha_continuous()
## Warning: Removed 2871 rows containing non-finite values (`stat_count()`).