nber_recessions_extract <- nber_recessions %>%
filter(Peak >= as.Date("1929-01-01"))
FAAt207 %>%
year_to_date %>%
filter(LineNumber %in% c(4, 11, 18, 26)) %>%
rename(variable = LineDescription) %>%
left_join(gdp_A, by = "date") %>%
mutate(DataValue = DataValue/value) %>%
filter(date >= as.Date("1929-01-01")) %>%
ggplot + geom_line(aes(x = date, y = DataValue, color = variable)) +
ylab("% of GDP") + xlab("") +
theme_minimal()+
geom_rect(data = nber_recessions_extract,
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_x_date(breaks = nber_recessions_extract$Peak,
labels = date_format("%y")) +
scale_y_continuous(breaks = 0.01*seq(0, 160, 0.2),
labels = scales::percent_format(accuracy = 0.2)) +
theme(legend.position = c(0.25, 0.85),
legend.title = element_blank(),
legend.text = element_text(size = 8),
legend.key.size = unit(0.9, 'lines'))
FAAt207 %>%
year_to_date %>%
filter(LineNumber %in% c(4, 11, 18, 26)) %>%
rename(variable = LineDescription) %>%
left_join(gdp_A, by = "date") %>%
mutate(DataValue = DataValue/value) %>%
filter(date >= as.Date("1929-01-01")) %>%
ggplot + geom_line(aes(x = date, y = DataValue, color = variable)) +
ylab("% of GDP") + xlab("") +
theme_minimal()+
geom_rect(data = nber_recessions_extract %>%
filter(Peak > as.Date("1927-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_x_date(breaks = nber_recessions_extract$Peak,
labels = date_format("%y")) +
scale_y_continuous(breaks = 0.01*seq(0, 160, 0.2),
labels = scales::percent_format(accuracy = 0.2)) +
theme(legend.position = c(0.25, 0.85),
legend.title = element_blank(),
legend.text = element_text(size = 8),
legend.key.size = unit(0.9, 'lines'))
FAAt207 %>%
year_to_date %>%
filter(LineNumber %in% c(37, 48, 49, 54, 57)) %>%
rename(variable = LineDescription) %>%
left_join(gdp_A, by = "date") %>%
mutate(DataValue = DataValue/value) %>%
filter(date >= as.Date("1929-01-01")) %>%
ggplot + geom_line(aes(x = date, y = DataValue, color = variable)) +
ylab("% of GDP") + xlab("") +
theme_minimal()+
geom_rect(data = nber_recessions_extract %>%
filter(Peak > as.Date("1927-01-01")),
aes(xmin = Peak, xmax = Trough, ymin = -Inf, ymax = +Inf),
fill = 'grey', alpha = 0.5) +
scale_x_date(breaks = nber_recessions_extract$Peak,
minor_breaks = "5 years",
labels = date_format("%y")) +
scale_y_continuous(breaks = 0.01*seq(0, 160, 0.2),
labels = scales::percent_format(accuracy = 0.2)) +
theme(legend.position = c(0.30, 0.8),
legend.title = element_blank(),
legend.text = element_text(size = 8),
legend.key.size = unit(0.9, 'lines'))
FAAt207 %>%
year_to_date %>%
mutate(year = year(date)) %>%
filter(year %in% c(1938, 1958, 1978, 1998, 2018)) %>%
group_by(year) %>%
mutate(DataValue = round(100*DataValue/DataValue[1], 1)) %>%
ungroup %>%
select(LineNumber, LineDescription, year, DataValue) %>%
spread(year, DataValue) %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}
FAAt207 %>%
year_to_date %>%
mutate(year = year(date)) %>%
filter(year %in% c(1938, 1958, 1978, 1998, 2018)) %>%
group_by(year) %>%
mutate(DataValue = round(DataValue)) %>%
ungroup %>%
select(LineNumber, LineDescription, year, DataValue) %>%
spread(year, DataValue) %>%
{if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}