Below you will find the coding and results of several measures of complexity, including number of words, number of distinct words, the density, and a graph of the distributions of word lengths for each author
# A tibble: 5,265 × 3
# Groups: author [7]
author word n
<chr> <chr> <int>
1 Lincoln the 256
2 Lincoln of 146
3 Lincoln to 135
4 FDR the 130
5 Jefferson the 130
6 Obama the 130
7 Reagan the 123
8 Obama and 114
9 Washington the 114
10 FDR of 109
# ℹ 5,255 more rows
<ggproto object: Class ScaleDiscrete, Scale, gg>
aesthetics: fill
axis_order: function
break_info: function
break_positions: function
breaks: waiver
call: call
clone: function
dimension: function
drop: TRUE
expand: waiver
get_breaks: function
get_breaks_minor: function
get_labels: function
get_limits: function
guide: legend
is_discrete: function
is_empty: function
labels: waiver
limits: NULL
make_sec_title: function
make_title: function
map: function
map_df: function
n.breaks.cache: NULL
na.translate: TRUE
na.value: NA
name: waiver
palette: function
palette.cache: NULL
position: left
range: environment
rescale: function
reset: function
scale_name: viridis_d
train: function
train_df: function
transform: function
transform_df: function
super: <ggproto object: Class ScaleDiscrete, Scale, gg>
labs(title ="Most distinctive words in each inaugaration note")
$title
[1] "Most distinctive words in each inaugaration note"
attr(,"class")
[1] "labels"
A Sentiment Analysis was completed as seen below. A graph and table can be seen of the most common positive and negative words
# A tibble: 619 × 3
word sentiment n
<chr> <chr> <int>
1 good positive 21
2 freedom positive 19
3 great positive 19
4 right positive 18
5 work positive 18
6 peace positive 17
7 free positive 16
8 well positive 15
9 confidence positive 11
10 happiness positive 11
# ℹ 609 more rows
Graph:
inaug_words |>inner_join(bing) |>count(word, sentiment, sort =TRUE) %>%group_by(sentiment) |>top_n(10) |>ungroup() |>mutate(word =reorder(word, n)) |>ggplot(aes(word, n, fill = sentiment)) +geom_col(show.legend =FALSE) +facet_wrap(vars(sentiment), scales ="free") +labs(y ="Inaugaration notes: Words that contribute the most to each sentiment",x =NULL) +scale_fill_viridis_d() +coord_flip() +theme_minimal()
Joining with `by = join_by(word)`
Selecting by n
Below you will find tables of the most common bigrams, and the most common bigrams after removing stop words.
inaug_speeches |>unnest_tokens(bigram, text, token ="ngrams", n =2) |>select(bigram) -> inaug_bigrams
inaug_bigrams %>%count (bigram, sort = T)
# A tibble: 10,876 × 2
bigram n
<chr> <int>
1 of the 146
2 in the 80
3 of our 55
4 to the 55
5 and the 38
6 to be 37
7 it is 35
8 by the 34
9 for the 30
10 that the 29
# ℹ 10,866 more rows
# A tibble: 2,399 × 2
bigram n
<chr> <int>
1 let us 18
2 fellow citizens 16
3 united states 11
4 american people 6
5 federal government 4
6 government can 4
7 one section 4
8 vice president 4
9 will endure 4
10 among us 3
# ℹ 2,389 more rows
Below you will find a graph showing the most common words that came after the words “i”, “live”, and “lead”.