Advanced Text Analysis with R

Before we get started, be sure that you have R, and R Studio downloaded and installed.

Today we will learn how to use the quanteda package and perform sentiment analysis and topic modeling on our texts!

Load (and install if necessary) the libraries!

library(quanteda)
## Package version: 2.1.2
## Parallel computing: 2 of 8 threads used.
## See https://quanteda.io for tutorials and examples.
## 
## Attaching package: 'quanteda'
## The following object is masked from 'package:utils':
## 
##     View
library(tidyverse)
## ── Attaching packages ────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.3     ✓ dplyr   1.0.2
## ✓ tidyr   1.1.2     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.0
## ── Conflicts ───────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(gutenbergr)
library(maps)
## 
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
## 
##     map
library(tm)
## Loading required package: NLP
## 
## Attaching package: 'NLP'
## The following object is masked from 'package:ggplot2':
## 
##     annotate
## The following objects are masked from 'package:quanteda':
## 
##     meta, meta<-
## 
## Attaching package: 'tm'
## The following objects are masked from 'package:quanteda':
## 
##     as.DocumentTermMatrix, stopwords
library(dplyr)
library(tidytext)

Today we will use the gutenbergr package to create different corpora. Feel free to switch out these texts with additional authors or works you are interested in analyzing.

#gutenberg_get_mirror(verbose = TRUE) #make sure the gutenberg download mirror is working & set up okay
#lets compare austen and dickens
austen <- gutenberg_works(author == "Austen, Jane") %>%
gutenberg_download(meta_fields = "title") #get Jane Austen works and inspect the titles

dickens <- gutenberg_works(author == "Dickens, Charles") %>%
gutenberg_download(meta_fields = "title") #same for Charles Dickens
View(dickens)
#download selected works of Dickens and Jane Austen
dickens <- gutenberg_download(c(46, 98, 588, 730, 766)) %>% 
  select(-gutenberg_id) %>% 
  mutate(author = "C. Dickens")
View(dickens)

austen <- gutenberg_download(c(105, 121, 158, 161, 1342))%>% 
  select(-gutenberg_id) %>% 
  mutate(author = "J. Austen")
View(austen)

#another option would be to just select different books you are interested in
#here we've got persuasion and a tale of two cities
books <- gutenberg_download(c(105, 98), meta_fields = "title")
books %>%
  count(title)
View(books)
tokens <- books %>%
  unnest_tokens(word, text)


#get counts of content words by including stop_words from tidytext:

token_counts <- tokens %>%
  anti_join(stop_words, by = "word") %>%
  count(title, word, sort = TRUE)

token_counts

Sentiment analysis!

#here are three different sentiment dictionaries for sentiment analysis
get_sentiments("nrc")
get_sentiments("bing")
get_sentiments("afinn")

#nrc has a variety of sentiments: joy, trust, negative, fear, positive etc
nrc_joy <- get_sentiments("nrc") %>% 
  filter(sentiment == "joy")

nrc_negative <- get_sentiments("nrc") %>%
  filter(sentiment == "negative")


#get all of dickens works
charlesdickens <- gutenberg_works(author == "Dickens, Charles") %>%
  gutenberg_download(meta_fields = "title")
View(charlesdickens)
#put it in tidy text format
dickens_books <- charlesdickens %>%
  group_by(title) %>%
  mutate(linenumber = row_number(),
         chapter = cumsum(str_detect(text, regex("^chapter [\\divxlc]",
                                                 ignore_case = TRUE)))) %>%
  ungroup() %>% unnest_tokens(word, text)

View(dickens_books)

#what words are associated with joy in great expectations?
dickens_books %>% filter(title == "Great Expectations") %>% inner_join(nrc_joy) %>% count(word, sort = T)

#how about negative sentiment?
dickens_books %>% filter(title == "Great Expectations") %>% inner_join(nrc_negative) %>% count(word, sort = T)


#get sentiment values using bing for all of dickens works on gutenberg
dickens_sentiment <- dickens_books %>%
  inner_join(get_sentiments("bing")) %>%
  count(title, index = linenumber %/% 80, sentiment) %>%
  spread(sentiment, n, fill = 0) %>%
  mutate(sentiment = positive - negative)

#filter to a specific book
dickens_twocities <- dickens_sentiment %>% filter(title == "A Tale of Two Cities")
View(dickens_twocities)
#great expectations
dickens_greatex <- dickens_sentiment %>% filter(title == "Great Expectations")
dickens_greatex

#sentiment analysis for A Tale of Two Cities
ggplot(dickens_twocities, aes(index, sentiment, fill = title)) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~title, ncol = 2, scales = "free_x")+ labs(x = "", y = "sentiment", title = "Sentiment in A Tale of Two Cities")

#test results of afinn with great expectations
afinn_dickens <- dickens_books %>%  filter((title == "Great Expectations")) %>% #filter by title
  inner_join(get_sentiments("afinn")) %>% #add in the sentiment lexicon
  group_by(index = linenumber %/% 80) %>% #using division to compare sentiment values across whole novel
  summarise(sentiment = sum(value)) %>% #summarise it
  mutate(method = "AFINN")

#check it out
View(afinn_dickens)

#plot it 
afinn_dickens %>% ggplot(aes(index, sentiment, fill = method)) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~method, ncol = 1, scales = "free_y")

Let’s test out sentiment analysis on A Modest Proposal with Jocker’s syuzhet package.

library(syuzhet)
modestprop <- paste("A Modest Proposal

For preventing the children of poor people in Ireland,
from being a burden on their parents or country,
and for making them beneficial to the publick.

by Dr. Jonathan Swift

1729




It is a melancholy object to those, who walk through this great town,
or travel in the country, when they see the streets, the roads, and
cabbin-doors crowded with beggars of the female sex, followed by three,
four, or six children, all in rags, and importuning every passenger for
an alms. These mothers, instead of being able to work for their honest
livelihood, are forced to employ all their time in stroling to beg
sustenance for their helpless infants who, as they grow up, either turn
thieves for want of work, or leave their dear native country, to fight
for the Pretender in Spain, or sell themselves to the Barbadoes.

I think it is agreed by all parties, that this prodigious number of
children in the arms, or on the backs, or at the heels of their
mothers, and frequently of their fathers, is in the present deplorable
state of the kingdom, a very great additional grievance; and therefore
whoever could find out a fair, cheap and easy method of making these
children sound and useful members of the commonwealth, would deserve so
well of the publick, as to have his statue set up for a preserver of
the nation.

But my intention is very far from being confined to provide only for
the children of professed beggars: it is of a much greater extent, and
shall take in the whole number of infants at a certain age, who are
born of parents in effect as little able to support them, as those who
demand our charity in the streets.

As to my own part, having turned my thoughts for many years upon this
important subject, and maturely weighed the several schemes of our
projectors, I have always found them grossly mistaken in their
computation. It is true, a child just dropt from its dam, may be
supported by her milk, for a solar year, with little other nourishment:
at most not above the value of two shillings, which the mother may
certainly get, or the value in scraps, by her lawful occupation of
begging; and it is exactly at one year old that I propose to provide
for them in such a manner, as, instead of being a charge upon their
parents, or the parish, or wanting food and raiment for the rest of
their lives, they shall, on the contrary, contribute to the feeding,
and partly to the clothing of many thousands.

There is likewise another great advantage in my scheme, that it will
prevent those voluntary abortions, and that horrid practice of women
murdering their bastard children, alas! too frequent among us,
sacrificing the poor innocent babes, I doubt, more to avoid the expence
than the shame, which would move tears and pity in the most savage and
inhuman breast.

The number of souls in this kingdom being usually reckoned one million
and a half, of these I calculate there may be about two hundred
thousand couple, whose wives are breeders; from which number I subtract
thirty thousand couple, who are able to maintain their own children,
(although I apprehend there cannot be so many under the present
distresses of the kingdom) but this being granted, there will remain a
hundred and seventy thousand breeders. I again subtract fifty thousand,
for those women who miscarry, or whose children die by accident or
disease within the year. There only remain a hundred and twenty
thousand children of poor parents annually born. The question therefore
is, How this number shall be reared and provided for? which, as I have
already said, under the present situation of affairs, is utterly
impossible by all the methods hitherto proposed. For we can neither
employ them in handicraft or agriculture; they neither build houses, (I
mean in the country) nor cultivate land: they can very seldom pick up a
livelihood by stealing till they arrive at six years old; except where
they are of towardly parts, although I confess they learn the rudiments
much earlier; during which time they can however be properly looked
upon only as probationers; as I have been informed by a principal
gentleman in the county of Cavan, who protested to me, that he never
knew above one or two instances under the age of six, even in a part of
the kingdom so renowned for the quickest proficiency in that art.

I am assured by our merchants, that a boy or a girl, before twelve
years old, is no saleable commodity, and even when they come to this
age, they will not yield above three pounds, or three pounds and half a
crown at most, on the exchange; which cannot turn to account either to
the parents or kingdom, the charge of nutriments and rags having been
at least four times that value.

I shall now therefore humbly propose my own thoughts, which I hope will
not be liable to the least objection.

I have been assured by a very knowing American of my acquaintance in
London, that a young healthy child well nursed, is, at a year old, a
most delicious nourishing and wholesome food, whether stewed, roasted,
baked, or boiled; and I make no doubt that it will equally serve in a
fricasee, or a ragoust.

I do therefore humbly offer it to publick consideration, that of the
hundred and twenty thousand children, already computed, twenty thousand
may be reserved for breed, whereof only one fourth part to be males;
which is more than we allow to sheep, black cattle, or swine, and my
reason is, that these children are seldom the fruits of marriage, a
circumstance not much regarded by our savages, therefore, one male will
be sufficient to serve four females. That the remaining hundred
thousand may, at a year old, be offered in sale to the persons of
quality and fortune, through the kingdom, always advising the mother to
let them suck plentifully in the last month, so as to render them
plump, and fat for a good table. A child will make two dishes at an
entertainment for friends, and when the family dines alone, the fore or
hind quarter will make a reasonable dish, and seasoned with a little
pepper or salt, will be very good boiled on the fourth day, especially
in winter.

I have reckoned upon a medium, that a child just born will weigh 12
pounds, and in a solar year, if tolerably nursed, encreaseth to 28
pounds.

I grant this food will be somewhat dear, and therefore very proper for
landlords, who, as they have already devoured most of the parents, seem
to have the best title to the children.

Infant’s flesh will be in season throughout the year, but more
plentiful in March, and a little before and after; for we are told by a
grave author, an eminent French physician, that fish being a prolifick
dyet, there are more children born in Roman Catholick countries about
nine months after Lent, than at any other season; therefore, reckoning
a year after Lent, the markets will be more glutted than usual, because
the number of Popish infants, is at least three to one in this kingdom,
and therefore it will have one other collateral advantage, by lessening
the number of Papists among us.

I have already computed the charge of nursing a beggar’s child (in
which list I reckon all cottagers, labourers, and four-fifths of the
farmers) to be about two shillings per annum, rags included; and I
believe no gentleman would repine to give ten shillings for the carcass
of a good fat child, which, as I have said, will make four dishes of
excellent nutritive meat, when he hath only some particular friend, or
his own family to dine with him. Thus the squire will learn to be a
good landlord, and grow popular among his tenants, the mother will have
eight shillings neat profit, and be fit for work till she produces
another child.

Those who are more thrifty (as I must confess the times require) may
flay the carcass; the skin of which, artificially dressed, will make
admirable gloves for ladies, and summer boots for fine gentlemen.

As to our City of Dublin, shambles may be appointed for this purpose,
in the most convenient parts of it, and butchers we may be assured will
not be wanting; although I rather recommend buying the children alive,
and dressing them hot from the knife, as we do roasting pigs.

A very worthy person, a true lover of his country, and whose virtues I
highly esteem, was lately pleased in discoursing on this matter, to
offer a refinement upon my scheme. He said, that many gentlemen of this
kingdom, having of late destroyed their deer, he conceived that the
want of venison might be well supplied by the bodies of young lads and
maidens, not exceeding fourteen years of age, nor under twelve; so
great a number of both sexes in every county being now ready to starve
for want of work and service: and these to be disposed of by their
parents if alive, or otherwise by their nearest relations. But with due
deference to so excellent a friend, and so deserving a patriot, I
cannot be altogether in his sentiments; for as to the males, my
American acquaintance assured me from frequent experience, that their
flesh was generally tough and lean, like that of our schoolboys, by
continual exercise, and their taste disagreeable, and to fatten them
would not answer the charge. Then as to the females, it would, I think,
with humble submission, be a loss to the publick, because they soon
would become breeders themselves: and besides, it is not improbable
that some scrupulous people might be apt to censure such a practice,
(although indeed very unjustly) as a little bordering upon cruelty,
which, I confess, hath always been with me the strongest objection
against any project, how well soever intended.

But in order to justify my friend, he confessed, that this expedient
was put into his head by the famous Psalmanaazor, a native of the
island Formosa, who came from thence to London, above twenty years ago,
and in conversation told my friend, that in his country, when any young
person happened to be put to death, the executioner sold the carcass to
persons of quality, as a prime dainty; and that, in his time, the body
of a plump girl of fifteen, who was crucified for an attempt to poison
the Emperor, was sold to his imperial majesty’s prime minister of
state, and other great mandarins of the court in joints from the
gibbet, at four hundred crowns. Neither indeed can I deny, that if the
same use were made of several plump young girls in this town, who
without one single groat to their fortunes, cannot stir abroad without
a chair, and appear at a playhouse and assemblies in foreign fineries
which they never will pay for, the kingdom would not be the worse.

Some persons of a desponding spirit are in great concern about that
vast number of poor people, who are aged, diseased, or maimed; and I
have been desired to employ my thoughts what course may be taken, to
ease the nation of so grievous an incumbrance. But I am not in the
least pain upon that matter, because it is very well known, that they
are every day dying, and rotting, by cold and famine, and filth, and
vermin, as fast as can be reasonably expected. And as to the young
labourers, they are now in almost as hopeful a condition. They cannot
get work, and consequently pine away from want of nourishment, to a
degree, that if at any time they are accidentally hired to common
labour, they have not strength to perform it, and thus the country and
themselves are happily delivered from the evils to come.

I have too long digressed, and therefore shall return to my subject. I
think the advantages by the proposal which I have made are obvious and
many, as well as of the highest importance.

For first, as I have already observed, it would greatly lessen the
number of Papists, with whom we are yearly overrun, being the principal
breeders of the nation, as well as our most dangerous enemies, and who
stay at home on purpose with a design to deliver the kingdom to the
Pretender, hoping to take their advantage by the absence of so many
good Protestants, who have chosen rather to leave their country, than
stay at home and pay tithes against their conscience to an episcopal
curate.

Secondly, The poorer tenants will have something valuable of their own,
which by law may be made liable to a distress, and help to pay their
landlord’s rent, their corn and cattle being already seized, and money
a thing unknown.

Thirdly, Whereas the maintainance of a hundred thousand children, from
two years old, and upwards, cannot be computed at less than ten
shillings a piece per annum, the nation’s stock will be thereby
encreased fifty thousand pounds per annum, besides the profit of a new
dish, introduced to the tables of all gentlemen of fortune in the
kingdom, who have any refinement in taste. And the money will circulate
among our selves, the goods being entirely of our own growth and
manufacture.

Fourthly, The constant breeders, besides the gain of eight shillings
sterling per annum by the sale of their children, will be rid of the
charge of maintaining them after the first year.

Fifthly, This food would likewise bring great custom to taverns, where
the vintners will certainly be so prudent as to procure the best
receipts for dressing it to perfection; and consequently have their
houses frequented by all the fine gentlemen, who justly value
themselves upon their knowledge in good eating; and a skilful cook, who
understands how to oblige his guests, will contrive to make it as
expensive as they please.

Sixthly, This would be a great inducement to marriage, which all wise
nations have either encouraged by rewards, or enforced by laws and
penalties. It would encrease the care and tenderness of mothers towards
their children, when they were sure of a settlement for life to the
poor babes, provided in some sort by the publick, to their annual
profit instead of expence. We should soon see an honest emulation among
the married women, which of them could bring the fattest child to the
market. Men would become as fond of their wives, during the time of
their pregnancy, as they are now of their mares in foal, their cows in
calf, or sows when they are ready to farrow; nor offer to beat or kick
them (as is too frequent a practice) for fear of a miscarriage.

Many other advantages might be enumerated. For instance, the addition
of some thousand carcasses in our exportation of barrel’d beef: the
propagation of swine’s flesh, and improvement in the art of making good
bacon, so much wanted among us by the great destruction of pigs, too
frequent at our tables; which are no way comparable in taste or
magnificence to a well grown, fat yearling child, which roasted whole
will make a considerable figure at a Lord Mayor’s feast, or any other
publick entertainment. But this, and many others, I omit, being
studious of brevity.

Supposing that one thousand families in this city, would be constant
customers for infants flesh, besides others who might have it at merry
meetings, particularly at weddings and christenings, I compute that
Dublin would take off annually about twenty thousand carcasses; and the
rest of the kingdom (where probably they will be sold somewhat cheaper)
the remaining eighty thousand.

I can think of no one objection, that will possibly be raised against
this proposal, unless it should be urged, that the number of people
will be thereby much lessened in the kingdom. This I freely own, and
was indeed one principal design in offering it to the world. I desire
the reader will observe, that I calculate my remedy for this one
individual Kingdom of Ireland, and for no other that ever was, is, or,
I think, ever can be upon Earth. Therefore let no man talk to me of
other expedients: Of taxing our absentees at five shillings a pound: Of
using neither clothes, nor houshold furniture, except what is of our
own growth and manufacture: Of utterly rejecting the materials and
instruments that promote foreign luxury: Of curing the expensiveness of
pride, vanity, idleness, and gaming in our women: Of introducing a vein
of parsimony, prudence and temperance: Of learning to love our country,
wherein we differ even from Laplanders, and the inhabitants of
Topinamboo: Of quitting our animosities and factions, nor acting any
longer like the Jews, who were murdering one another at the very moment
their city was taken: Of being a little cautious not to sell our
country and consciences for nothing: Of teaching landlords to have at
least one degree of mercy towards their tenants. Lastly, of putting a
spirit of honesty, industry, and skill into our shopkeepers, who, if a
resolution could now be taken to buy only our native goods, would
immediately unite to cheat and exact upon us in the price, the measure,
and the goodness, nor could ever yet be brought to make one fair
proposal of just dealing, though often and earnestly invited to it.

Therefore I repeat, let no man talk to me of these and the like
expedients, till he hath at least some glympse of hope, that there will
ever be some hearty and sincere attempt to put them into practice.

But, as to myself, having been wearied out for many years with offering
vain, idle, visionary thoughts, and at length utterly despairing of
success, I fortunately fell upon this proposal, which, as it is wholly
new, so it hath something solid and real, of no expence and little
trouble, full in our own power, and whereby we can incur no danger in
disobliging England. For this kind of commodity will not bear
exportation, and flesh being of too tender a consistence, to admit a
long continuance in salt, although perhaps I could name a country,
which would be glad to eat up our whole nation without it.

After all, I am not so violently bent upon my own opinion, as to reject
any offer, proposed by wise men, which shall be found equally innocent,
cheap, easy, and effectual. But before something of that kind shall be
advanced in contradiction to my scheme, and offering a better, I desire
the author or authors will be pleased maturely to consider two points.
First, As things now stand, how they will be able to find food and
raiment for a hundred thousand useless mouths and backs. And secondly,
There being a round million of creatures in humane figure throughout
this kingdom, whose whole subsistence put into a common stock, would
leave them in debt two million of pounds sterling, adding those who are
beggars by profession, to the bulk of farmers, cottagers and labourers,
with their wives and children, who are beggars in effect; I desire
those politicians who dislike my overture, and may perhaps be so bold
to attempt an answer, that they will first ask the parents of these
mortals, whether they would not at this day think it a great happiness
to have been sold for food at a year old, in the manner I prescribe,
and thereby have avoided such a perpetual scene of misfortunes, as they
have since gone through, by the oppression of landlords, the
impossibility of paying rent without money or trade, the want of common
sustenance, with neither house nor clothes to cover them from the
inclemencies of the weather, and the most inevitable prospect of
intailing the like, or greater miseries, upon their breed for ever.

I profess in the sincerity of my heart, that I have not the least
personal interest in endeavouring to promote this necessary work,
having no other motive than the publick good of my country, by
advancing our trade, providing for infants, relieving the poor, and
giving some pleasure to the rich. I have no children, by which I can
propose to get a single penny; the youngest being nine years old, and
my wife past child-bearing.")

library(zoo)
get_sentiment(modestprop)

modestprop_sentences_v <- get_sentences(modestprop)
#get raw sentiments based on sentences
modestprop_sentiments_v <- get_sentiment(modestprop_sentences_v) 
modestprop_sentiments_v
#plot it
plot(
  modestprop_sentiments_v,
  type = "l",
  xlab = "Novel Time",
  ylab = "Sentiment",
  main = "Raw Sentiment Values in A Modest Proposal" )

#testing different methods of smoothing, this one uses a rolled mean
amp_window <- round(length(modestprop_sentiments_v)*.1)
#gets rolling mean values for sentiments using the window above
amp_rolled <- rollmean(modestprop_sentiments_v, k = amp_window)

#this creates a scaled vector of values from 0 to 1; making it possible to compare different plots more easier
amp_scaled <- rescale_x_2(amp_rolled) 


#plot it
plot(amp_scaled$x, amp_scaled$z,
     type="l",
     col="blue",
     xlab="Narrative Time",
     ylab="Emotional Valence",
     main = "A Modest Proposal with Rolling Means"
)

Utilizing the quanteda package.

austen2 <- gutenberg_download(c(105, 121, 158, 161, 1342))%>% 
  mutate(author = "Austen")
View(austen2)
austen_forquanteda <- austen2 %>% group_by(gutenberg_id) %>% summarize(text = paste(text, collapse = "\n"))
View(austen_forquanteda)
austencorpus <- quanteda::corpus(austen_forquanteda)
summary(austencorpus)



#repeat for Dickens 46, 98, 588, 730, 766 "A Christmas Carol", "A Tale of Two Cities", "Master Humphrey's Clock", "Oliver Twist", "David Copperfield"
dickens2 <- gutenberg_download(c(46, 98, 588, 730, 766))%>% 
  mutate(author = "Dickens")
View(dickens2)

dickens_forquanteda <- dickens2 %>% group_by(gutenberg_id) %>% summarize(text = paste(text, collapse = "\n"))
dickenscorpus <- quanteda::corpus(dickens_forquanteda)
summary(dickenscorpus)

names(dickens_forquanteda) <- c("A Christmas Carol", "A Christmas Carol", "A Tale of Two Cities", "Master Humphrey's Clock", "Oliver Twist", "David Copperfield") #replace with single or double quotes if using full name of texts

Topic modeling with two different packages.

library(stm)
set.seed(100)

#create stemmed version of the austen corpus with quanteda
stemmedausten <- dfm(austencorpus, remove = stopwords("english"), stem = TRUE, remove_punct = TRUE)
#view it
stemmedausten[, 1:5]
#topfeatures
topfeatures(stemmedausten, 20) 

#run stm topic modeling by Roberts et al.
if (require(stm)) {
    lda_fit20 <- stm(stemmedausten, K = 20, verbose = FALSE)
    plot(lda_fit20)    
}


#load topic models package
library(topicmodels)
#make another basic document feature matrix of austen corpus, this time without stemming
austen_dfm <- dfm(austencorpus, remove = stopwords("english"), stem =F, remove_punct = TRUE)
austen_dfm

toptenausten = LDA(convert(austen_dfm, to = "topicmodels"), k = 10)
getTerms(toptenausten, 20) #output is top words associated with each topic

t(topics(toptenausten, 2)) #top topic groups per text

Works Cited

Benoit K, Watanabe K, Wang H, Nulty P, Obeng A, Müller S, Matsuo A. 2018. quanteda: An R package for the quantitative analysis of textual data. Journal of Open Source Software, 3(30), 774. doi: 10.21105/joss.00774
Bing, Liu. 2015. Sentiment Analysis: Mining Opinions, Sentiments, and Emotions.
Clark, Michael. 2018. An Introduction to Text Processing and Analysis with R.
Feinerer, Ingo. 2020. Introduction to the tm Package: Text Mining in R.
Grün, Bettina & Kurt Hornik. topicmodels: An R Package for Fitting Topic Models.
Hvitfeldt, Emil & Julia Sigle. 2020. textdata: download and load various text datasets.
Jockers, M. 2015. Syuzhet: Extract sentiment and plot arcs from text.
Jockers, M. 2015. That Sentimental Feeling Jockers, M. 2016. More syuzhet validation
Roberts, Margaret, Brandon Stewart, and Dustin Tingley. Stm: R Package for Structural Topic Models.
Robinson, David. 2020. gutenbergr vignette.
Robinson, David. 2020. gutenbergr: Search and download public domain texts from Project Gutenberg. v. 0.20 Silge, Julia, and David Robinson. 2016. tidytext R package.
Silge, Julia, and David Robinson. 2020. Text Mining with R: A Tidy Approach.
Wickam, Hadley et al. 2019. Welcome to the tidyverse.