Harold Nelson
10/14/2019
Load all of our usual packages. Add fredr.
## ── Attaching packages ─────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1 ✔ purrr 0.2.5
## ✔ tibble 2.0.1 ✔ dplyr 0.8.0.1
## ✔ tidyr 0.8.1 ✔ stringr 1.4.0
## ✔ readr 1.1.1 ✔ forcats 0.3.0
## ── Conflicts ────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
unratef = fredr_series_observations(
series_id = "UNRATE",
observation_start = as.Date("1980-04-01"),
frequency = "q")
unratef$president = Presidents$President[1:158]
unrate = unratef$value
ung = ggplot(unratef,aes(x=date,y=value)) +
geom_point(size=3) +
geom_mark_rect(aes(fill = president,label=president))
ung
infcpif = fredr_series_observations(
series_id = "CPIAUCSL",
observation_start = as.Date("1980-04-01"),
frequency = "q",
units = "chg")
infcpif$president = Presidents$President[1:158]
infcpi = infcpif$value
rg = ggplot(infcpif,aes(x=date,y=value)) +
geom_point(aes(color=president),size=3) +
geom_mark_rect(aes(fill=president,
label=president),show.legend=F)
rg
lfpr25_54f = fredr_series_observations(
series_id = "LNS11300060",
observation_start = as.Date("1980-04-01"),
frequency = "q",
units = "chg")
lfpr25_54 = lfpr25_54f$value
rg = ggplot(lfpr25_54f,aes(x=date,y=value)) +
geom_point(size=.5)
ggplotly(rg)
Make the dataframe.
## Observations: 158
## Variables: 6
## $ Date <date> 1980-04-01, 1980-07-01, 1980-10-01, 1981-01-01, 1981-…
## $ President <chr> "Reagan", "Reagan", "Reagan", "Reagan", "Reagan", "Rea…
## $ realgdp <dbl> 1.3, -8.0, -0.5, 7.7, 8.1, -2.9, 4.9, -4.3, -6.1, 1.8,…
## $ infcpi <dbl> 2.66666667, 1.53333333, 2.33333333, 2.36666667, 1.8333…
## $ lfpr25_54 <dbl> -0.06666667, 0.03333333, 0.10000000, 0.36666667, 0.333…
## $ unrate <dbl> 7.3, 7.7, 7.4, 7.4, 7.4, 7.4, 8.2, 8.8, 9.4, 9.9, 10.7…
nrow(Presidents)