For this sentiment analysis, I’m using a dataset that was generated through my work at the UNC Makerspaces. Each semester, we put on a showcase event called MakerFest where students can exhibit the projects they have made throughout the semester.
When I create the exhibitor programs for these events, I have an Excel file that I use that contains exhibitor names, student-created exhibit titles, student-written exhibit blurbs, and any associated academic courses. Before uploading into Posit, I went ahead and de-identified the data, converting the ‘Names’ column into an ‘ID’ column with randomly assigned ID numbers.
library(dplyr)
library(readr)
library(tidyverse)
library(writexl)
library(readxl)
library(tidytext)
library(textdata)
library(ggplot2)
library(wordcloud2)
makerfest_info <- read_excel("data/ECI588MakerFestFallBlurbs.xlsx")
makerfest_blurb_tokens <-
makerfest_info |>
unnest_tokens(output = word,
input = Description)
makerfest_blurb_tokens <- select(makerfest_blurb_tokens, ID, Course, word)
makerfest_blurb_tokens
## # A tibble: 9,275 × 3
## ID Course word
## <dbl> <chr> <chr>
## 1 1 Individual this
## 2 1 Individual is
## 3 1 Individual an
## 4 1 Individual enclosure
## 5 1 Individual to
## 6 1 Individual hold
## 7 1 Individual hollow
## 8 1 Individual cathode
## 9 1 Individual lamps
## 10 1 Individual used
## # … with 9,265 more rows
tidy_blurb_tokens <-
makerfest_blurb_tokens |>
anti_join(stop_words, by = "word")
For this project, I settled on two research questions:
What were the most common words that MakerFest exhibitors used to explain their projects?
Was there a difference in positive and negative sentiment across courses?
I was deciding between AFINN and NRC to choose a sentiment lexicon. Ultimately, I decided to go with NRC since it has emotion variables in addition to positive/negative sentiment variables, which I thought was kind of interesting.
nrc <- get_sentiments("nrc")
nrc
## # A tibble: 13,872 × 2
## word sentiment
## <chr> <chr>
## 1 abacus trust
## 2 abandon fear
## 3 abandon negative
## 4 abandon sadness
## 5 abandoned anger
## 6 abandoned fear
## 7 abandoned negative
## 8 abandoned sadness
## 9 abandonment anger
## 10 abandonment fear
## # … with 13,862 more rows
blurb_sentiment_nrc <- inner_join(tidy_blurb_tokens, nrc, by = "word")
blurb_sentiment_nrc
## # A tibble: 1,932 × 4
## ID Course word sentiment
## <dbl> <chr> <chr> <chr>
## 1 1 Individual hollow negative
## 2 1 Individual hollow sadness
## 3 1 Individual system trust
## 4 1 Individual real positive
## 5 1 Individual real trust
## 6 1 Individual time anticipation
## 7 1 Individual reason positive
## 8 1 Individual cad anger
## 9 1 Individual cad disgust
## 10 1 Individual cad negative
## # … with 1,922 more rows
summary_nrc_blurb <- blurb_sentiment_nrc %>%
filter(sentiment %in% c("positive", "negative")) %>%
group_by(Course) %>%
count(sentiment, sort = TRUE) %>%
spread(sentiment, n) %>%
mutate(percent_pos = ((positive)/(positive + negative))*100) %>%
mutate(percent_neg = ((negative)/(positive + negative))*100)
summary_nrc_blurb
## # A tibble: 9 × 5
## # Groups: Course [9]
## Course negative positive percent_pos percent_neg
## <chr> <int> <int> <dbl> <dbl>
## 1 AMST 460H 2 14 87.5 12.5
## 2 APPL 110 117 402 77.5 22.5
## 3 APPL 285 7 13 65 35
## 4 ECON 125 1 4 80 20
## 5 Individual 26 89 77.4 22.6
## 6 INLS 690 7 16 69.6 30.4
## 7 PHYS 100 2 4 66.7 33.3
## 8 SPAN 329 6 27 81.8 18.2
## 9 SPAN 344 14 46 76.7 23.3
I decided to generate word counts and create a word cloud to answer my first research question. I created a simple bar graph to answer my second research question.
tidy_blurb_tokens <- tidy_blurb_tokens |>
count(word, sort = TRUE)
wordcloud2(tidy_blurb_tokens)
summary_nrc_blurb_plot <- ggplot(data = summary_nrc_blurb) +
geom_bar(aes(x = Course, weight = percent_pos, fill = percent_pos)) +
labs(title="Percentage of Positive Words Per Course",
x ="Course", y = "Percentage Positive") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
legend.position = "none")
summary_nrc_blurb_plot
Let’s return to the original research questions:
The most common words were tool-oriented words: 3D, laser, cutter, etc. There were also a number of process-oriented words (e.g. design, create, etc.) as well as some that seem to be describing the type of project (e.g. product, box, wood, etc.)
Somewhat, although the sample size for the different courses varied widely. However, we can generally observe that AMST 460H had a higher percentage of positive words than the other courses, while courses like PHYS 100 tended to have a lower percentage of positive words.