inaug_dat <- read_csv("inaug_speeches.csv")
head(inaug_dat)
## # A tibble: 6 x 5
## X1 Name `Inaugural Address` Date text
## <dbl> <chr> <chr> <chr> <chr>
## 1 4 George Wa… First Inaugural Ad… Thursday, … "Fellow-Citizens of the Sena…
## 2 5 George Wa… Second Inaugural A… Monday, Ma… "Fellow Citizens: \xa0\xa0I…
## 3 6 John Adams Inaugural Address Saturday, … "\xa0\xa0WHEN it was first p…
## 4 7 Thomas Je… First Inaugural Ad… Wednesday,… "Friends and Fellow-Citizens…
## 5 8 Thomas Je… Second Inaugural A… Monday, Ma… "\xa0\xa0PROCEEDING, fellow-…
## 6 9 James Mad… First Inaugural Ad… Saturday, … "\xa0\xa0UNWILLING to depart…
Clean the data.
dat <-
inaug_dat %>%
transmute(president = str_to_lower(Name) %>% str_replace_all(.," ","_"),
address = case_when(
str_detect(`Inaugural Address`,"First") ~ "first",
str_detect(`Inaugural Address`,"Second") ~ "second",
str_detect(`Inaugural Address`,"Third") ~ "third",
str_detect(`Inaugural Address`,"Fourth") ~ "fourth",
T ~ "first"),
date = as.Date(Date,"%A, %B %d, %Y"),
year = lubridate::year(date),
length = str_count(text),
text = text)
# Adjust for one problematic date
dat[dat$president=="bill_clinton" & dat$address=="second",]$date = as.Date("1997-01-20")
dat[dat$president=="bill_clinton" & dat$address=="second",]$year = 1997
head(dat)
## # A tibble: 6 x 6
## president address date year length text
## <chr> <chr> <date> <dbl> <int> <chr>
## 1 george_washi… first 1789-04-30 1789 8641 "Fellow-Citizens of the Senate …
## 2 george_washi… second 1793-03-04 1793 805 "Fellow Citizens: \xa0\xa0I AM…
## 3 john_adams first 1797-03-04 1797 13914 "\xa0\xa0WHEN it was first perc…
## 4 thomas_jeffe… first 1801-03-04 1801 10170 "Friends and Fellow-Citizens: …
## 5 thomas_jeffe… second 1805-03-04 1805 12947 "\xa0\xa0PROCEEDING, fellow-cit…
## 6 james_madison first 1809-03-04 1809 7031 "\xa0\xa0UNWILLING to depart fr…
Answer: Not really. Though the variation in speech length varies less after 1950.
dat %>%
ggplot(aes(year,length)) +
geom_line() +
geom_point() +
geom_smooth(method="loess",se=F)