Modify the ggplot below to add:
ggplot(data = t_cpi) +
geom_point(mapping = aes(x = d, y = price_as_percent, color = title)) +
geom_vline(xintercept = ymd("2012-01-01")) +
geom_hline(yintercept = 1.00) +
geom_rect(xmin = ymd("2022-01-01"), xmax = ymd("2023-01-01"), ymin = 1.25, ymax = 1.50,
alpha = 0.003,
fill = "green")
Modify the ggplot below to add:
library(ggrepel)
t_2022 <- filter(t_cpi, year(d) == 2022, month(d) == 1)
ggplot(data = t_2022) +
geom_point(mapping = aes(x = d, y = price_as_percent, color = title)) +
geom_label_repel(mapping = aes(x = d, y = price_as_percent, label = title)) +
labs(x = 'Date', y = 'Price%') +
theme_bw()
Modify the ggplot below to add:
library(scales)
t_2022 <- filter(t_cpi, year(d) == 2022)
ggplot(data = t_2022) +
geom_line(mapping = aes(x = d, y = price_as_percent, color = title)) +
scale_y_continuous(labels = label_percent(accuracy = 0.1)) +
scale_x_date(breaks = "2 months",
date_labels = "%b")
Combine the options above to make what you think is an attractive chart. Publish your project, and put the URL below:
Published URL: https://rpubs.com/brycek/buda451-hw7
t_cpi_2 <- t_cpi
t_cpi_2$year <- format(as.Date(t_cpi_2$d), "%Y")
ggplot(data = t_cpi_2, aes(x = as.factor(year(d)), y = price_as_percent, fill = title)) +
geom_boxplot() +
facet_wrap(~title) +
labs(title = "Price Variation by Year",
subtitle = "2012-2022",
x = "Year",
y = "Price") +
scale_y_continuous(labels = label_percent(accuracy = 0.1)) +
scale_x_discrete(breaks = NULL) +
geom_hline(yintercept = 1.00, alpha = 0.3) +
theme_minimal()