# Count documents by President and add as a variable
data_corpus_inaugural %>%
add_count(President) %>%
summary(n = 10)
# Add total count to each document
data_corpus_inaugural %>%
head() %>%
add_tally() %>%
summary()
# Count by multiple variables
data_corpus_inaugural %>%
add_count(Party, President) %>%
summary(n = 10)
# Use custom name
data_corpus_inaugural %>%
add_count(Party, name = "party_count") %>%
summary(n = 10)
# Add tally to show total count
data_corpus_inaugural %>%
slice(1:6) %>%
add_tally() %>%
summary()
Run the code above in your browser using DataLab