Data Analysis

Analysis Overview

I employed four methodologies for data analysis: sentiment analysis, word frequencies, coding, and close reading. Sentiment analysis and word frequency studies are forms of quantitative research; close reading is thoroughly qualitative. Coding, a strategy drawn from the social sciences, has both quantitative and qualitative elements. I provided fuller explanations of each method below.

My methodologies varied from chapter to chapter depending on the size and content of the data subset I was working with. In general, I utilized one or more quantitative methods to determine patterns in the data subset as a whole. I then turned to close readings of examples from trends suggested in the quantitative analysis. Close reading is therefore woven throughout all three chapters in the project. The quantitative methods used for each chapter are outlined in Table 2.

Table 2. Methodologies used in each chapter

Affect & Historical EmpathySentiment analysis, word frequencies
The Attention Economy & Historical SignificanceWord frequencies, coding
GIFs from a History ClassSentiment analysis, word frequencies, coding

I conducted sentiment analysis and word frequency studies using the programming language R and software for working with the language, R Studio. R is a common language for digital humanities work and a number of very useful packages exist to make text mining simpler and more robust for digital humanists. I utilized the tidyverse collection and tidytext package to import, transform, and quantify data. The ggplot2 and wordcloud2 packages served as the primary software for visualizations. I also used sentimentr (detailed below) for sentiment analysis.

Numerous resources for R beginners exist as well. Articles from The Programming Historian, specifically Nabeel Siddiqui’s “Data Wrangling and Management with R” and “Basic Text Processing in R” by Taylor Arnold and Lauren Tilton served as a useful starting point. Hadley Wickham’s R for Data Science and Julia Silge and David Robinson’s Tidy Text Mining with R provided tutorials and examples for more complex work. All R work for this dissertation can be viewed in the R Script available in Downloads & Datasets.

Sentiment Analysis

Person holding balloons shaped like emoticons against a brightly painted wall
Photo by Lidya Nada on Unsplash

Sentiment analysis is a form of text mining used to determine the opinions or emotions present in a word, phrase, sentence, or longer passage of text. This form of analysis uses pre-existing lexicons created using machine-learning and crowdsourcing to detect the presence of positive or negative sentiment. Sentiment analysis is accomplished by comparing a dataset with one or more of the pre-existing lexicons.

The AFINN, Bing, and NRC lexicons are common for sentiment analysis and each has its own benefits. However, I chose to use the sentimentr package for R. Sentiment analysis using AFINN, Bing, and NRC, which are included in the tidytext package, offers a word lookup function for comparing a dataset to the lexicons and scoring the dataset accordingly. The lexicons are excellent for identifying positive, negative, and emotionally charged words in a dataset, but are not as beneficial for evaluating the overarching sentiment of longer passages of text. By contrast, the sentimentr package excels at evaluating the average sentiment of sentences.

The sentimentr package combines word lookups with algorithms that account for valence shifters; that is, words that negate, amplify, or moderate another word in a sentence. In the phrase “not good,” for instance, “not” is a valence shifter. Sentimentr compares the words in each sentence to two lexicons: an augmented version of the dictionary Matthew Jockers created for the syuzhet package (11,710 words) and the Hu & Liu lexicon augmented by Rinker (6,874 words). Each word in the sentence receives a numeric score. Words that are positive or negative in the lexicons receive -1 or +1, respectively. Valence shifters receive weighted scores depending on their placement in a sentence and/or the scores of the words grouped together (a polarity cluster). The package’s algorithms produce an average score for each sentence by dividing the sum of word scores by the number of words in the sentence.

Word Frequencies

Determining word frequencies, like sentiment analysis, is a form of text mining. This is arguably the most basic form of text mining and is a good starting point for identifying common words in a large dataset. A common form of word frequency visualization is a weighted word cloud in which more common words appear larger than less common ones or only the top-ranking words appear.

Figure 1. Word cloud of 100 most frequent words in All Tweets Dataset

Word cloud displaying most frequent words in All Tweets Dataset. The words that stand out most clearly are "significant," "life," "women," "people," "religion," and "god."

I employ word frequency studies in all three chapters of the dissertation. As was the case with sentiment analysis, I used the tidyverse collection and tidytext packages in RStudio to compute word frequencies for the Twitter data. Functions in these packages allow the user to tokenize data into individual words and then group and count the words to determine frequencies. In order to ensure that the frequencies were not skewed by frequent but meaningless words (such as “a,” “to,” and “the”), I joined my datasets with the stop words dataset built into the tidytext package. The join enabled me to filter words like “a,” “and,” and “the” out of the datasets. As noted in the data cleaning section, I also removed hashtags, usernames, punctuation, and special characters from the dataset as these elements would also have distorted the analysis (for example, the class hashtag, #hwc111, appeared in virtually ever tweet).

After removing stop words, hashtags, usernames, punctuation, and special characters, I had accurate lists of the most frequent words in my datasets. Yet the lists still did not necessarily reflect the most important words in the datasets. To determine the words that were most significant within and unique to the dataset, I joined my dataset to a dataset based on the Google Web Trillion Word Corpus provided by Peter Novig and shared by Arnold and Tilton in “Basic Text Processing in R.” The join allowed me to compare relative word frequencies in the Twitter datasets with relative frequencies of words in English generally. As Silge and Richardson argue, the combination of low relative frequency in English plus high raw frequency in the text tends to point to the unique concerns present in a document.


Paper tag and string
Photo by Brett Jordan on Unsplash

As I detail in Project Development, I used coding extensively in the first drafts of “Hashtag History.” I subsequently replaced much of the coding work with text-mining in R or close reading because the coding was overly subjective and not feasible for working with larger subsets of the Twitter data. Still, my initial coding established common themes and influenced my qualitative analysis in the final versions of each chapter.

Coding, like sentiment analysis and the study of word frequencies, helps a researcher identify patterns in a large body of text. But unlike text-mining practices, coding involves the researcher’s judgment rather than the judgment of algorithms. Coding, in the social sciences, involves labeling passages of text according to common themes. These themes can be deductive (the researcher allows themes to emerge from the text) or inductive (the researcher employs themes from other scholarship to make sense of the text).

Thematic coding can be used quantitatively or qualitatively. A basic quantitative use of coding might be counting the number of times a theme appears in order to understand which themes are most prevalent. Codes are also useful for qualitative analysis because coding can be used to find and label clear examples of themes within a dataset. Many researchers use coding both for both quantitative and qualitative purposes in their work.

Close Reading

Open book
Photo by Jonas Jacobsson on Unsplash

Close reading, unlike coding or the quantitative methods listed above, is less interested in the big picture than in the deep details of a small portion of text. Frequently employed by historians, history educators, and literary scholars, close reading requires the reader to read and re-read in order to understand form, patterns, and meanings. Close reading attends to specific word choice, the use of punctuation, and stylistic choices within a text. Close reading also requires the researcher to account for context; everything from the surrounding paragraphs to a broad historical background can help lend meaning to the text.

Close reading is woven through all three thematic chapters of “Hashtag History.” Sentiment analysis, word frequencies, and coding frame the big picture while close reading analysis of the layers of meaning present in individual tweets, sentences, and images. In “Affect & Historical Empathy,” sentiment analysis pointed to the presence of specific sentiments and emotions in students’ tweets; close reading allowed me to account for why those emotions are present. In “The Attention Economy & Historical Significance,” word frequencies helped me identify what captured students’ attention within the course while close reading pointed to their explanations of why specific content was attractive.

Close reading was especially important in “GIFs from a History Class,” which focuses on students’ use of GIFs as a mode of expressing their understandings of history. GIFs are inherently multilayered. The brief, animated images derive meaning from the original context of the image, from the circulation of an image on the web, and from the GIF user’s intent in sharing the image. Close reading was the best methodology for diving into the many layers of meaning carried by the GIFs students used in my course.