How do we know if students enjoy a class without asking them? One way is to look deep into their conversiations during group discussions. This project conducts a sentiment analysis on students’ text chat in a game-based learning environment aiming to understand the sentiment level they have in the classes.
Context
The data was collected from an implementation of a game-based learning environment in a middle-school science classroom. In this game, the students form small groups and learn about underwater ecosystem by exploring and collecting data at an island with local fish farmers. The game is embedded with a chat feature which allows students to message group members to discuss the task and questions they receive in the game.
One class of 23 7th grade students participated in this study. The students took 6 days in total to complete the game playing and the chat data of each day is organized in csv files with four columns: Timestamp, Username, Message, and Location.
Research Question
What is the overall sentiment score of students’ game playing?
How does the sentiment score change over-time?
What are some differences of the sentiment score across locations in the game?
Step 1: Data Preparation and Wrangling
1.1 Combine CSV Files
# Load necessary librarieslibrary(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Attaching package: 'tidygraph'
The following object is masked from 'package:stats':
filter
library(ggraph)library(igraph)
Attaching package: 'igraph'
The following object is masked from 'package:tidygraph':
groups
The following objects are masked from 'package:lubridate':
%--%, union
The following objects are masked from 'package:dplyr':
as_data_frame, groups, union
The following objects are masked from 'package:purrr':
compose, simplify
The following object is masked from 'package:tidyr':
crossing
The following object is masked from 'package:tibble':
as_data_frame
The following objects are masked from 'package:stats':
decompose, spectrum
The following object is masked from 'package:base':
union
Combine the data of the 6 days into one csv file.
# File paths for the CSV filesfile_paths <-c("Data/CM1G1.csv", "Data/CM1G2.csv", "Data/CM1G3.csv", "Data/CM1G4.csv","Data/CM1G5.csv", "Data/CM1G6.csv")# Read and combine the CSV filescombined_data <-lapply(file_paths, read_csv) %>%bind_rows()
Warning: One or more parsing issues, call `problems()` on your data frame for details,
e.g.:
dat <- vroom(...)
problems(dat)
Rows: 244 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Username, Message, Location
dttm (1): Timestamp
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 360 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Username, Message, Location
dttm (1): Timestamp
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 140 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Username, Message, Location
dttm (1): Timestamp
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Warning: One or more parsing issues, call `problems()` on your data frame for details,
e.g.:
dat <- vroom(...)
problems(dat)
Rows: 232 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Username, Message, Location
dttm (1): Timestamp
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 342 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Username, Message, Location
dttm (1): Timestamp
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 98 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Username, Message, Location
dttm (1): Timestamp
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
1.2 Data Cleaning and Preparation
The game has a collaborative task call the “TIDE board” which is places in a conference from in the game envitoment at where the students discuss the evidence they collect and answer questions collaboratively. The other places in the game include fish farms, hatchery, the lodge, etc, at where the students explore the island and talk to NPCs.
So, here, all the locations are separated into “TIDE” and “Other”.
# Data cleaning for 'Location' columnlibrary(stringr)combined_data$Location <-as.character(str_trim(combined_data$Location))combined_data$Location <-ifelse(grepl("TIDE", combined_data$Location, ignore.case =TRUE), "TIDE", "Other")
# A tibble: 6 × 2
sender target
<chr> <chr>
1 elliott084 Hiiiiiiiiiiiiiii :D
2 elliott084 I has a phone
3 claire086 hey!
4 cole085 hola
5 elliott084 yeah I love this already
6 elliott084 you can moon walk guys
Warning: Using the `size` aesthetic in this geom was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` in the `default_aes` field and elsewhere instead.
3.3 Build a Network
# Build a network using ggraphnetwork_plot <-ggraph(network, layout ="fr") +geom_edge_link()# View the network plotnetwork_plot
3.4 Add Nodes
# Add nodes to the network plotnetwork_plot <- network_plot +geom_node_point(size =5)# View the network plot with nodesnetwork_plot
3.5 Finalized Network Visualization
#Finalizing the network plotnetwork_plot +theme_minimal() +ggtitle("Network Visualization")
Step 4: Sentiment Analysis Modeling
4.1 Performing VADER Sentiment Analysis
# Perform VADER Sentiment Analysissummary_vader <-vader_df(combined_data$Message)# Joining Sentiment Scores with Original Datacombined_data_with_sentiment <-inner_join(combined_data, summary_vader, by =c("Message"="text"))
Warning in inner_join(combined_data, summary_vader, by = c(Message = "text")): Detected an unexpected many-to-many relationship between `x` and `y`.
ℹ Row 14 of `x` matches multiple rows in `y`.
ℹ Row 14 of `y` matches multiple rows in `x`.
ℹ If a many-to-many relationship is expected, set `relationship =
"many-to-many"` to silence this warning.
# Visualization of Sentiment Over Timecombined_data_with_sentiment$Timestamp <-as.POSIXct(combined_data_with_sentiment$Timestamp)ggplot(combined_data_with_sentiment, aes(x = Timestamp, y = compound)) +geom_line() +ggtitle("Sentiment Change Over Time")
Sentiment Differences Across Locations
# Sentiment Differences Across Locationssentiment_by_Location <- combined_data_with_sentiment %>%group_by(Location) %>%summarise(avg_sentiment =mean(compound, na.rm =TRUE))ggplot(sentiment_by_Location, aes(x = Location, y = avg_sentiment, fill = Location)) +geom_bar(stat ="identity") +ggtitle("Sentiment Differences Across Locations")
Communication
1. Overall Sentiment
The overall sentiment score is around 0.33, which indicates that the students’ conversiations are generally positive.
1. Sentiment Change Over Time
The visualization “Sentiment Change Over Time” provides a clear representation of how students’ sentiment fluctuates over the observed period. Since May 6th and 7th 2023 are weekends, there are no data collected from these two days, and the sentiment score of these two days are shown as 0. The scores went down raptly at the approximately second half of the class on May 3rd, May 5th, May 9th, and May 11th. Possible reasons for this include student’s patience and motivation going down at the end of the class, technical issues, abuse of the chat messages, etc.
2. Sentiment Differences Across Locations
The bar chart “Sentiment Differences Across Locations” helps to compare the average sentiment across different locations, revealing any significant differences. Surprisingly, the sentiment of TIDE is higher than that of the other locations, although not very much. This result may indicate that students were more motivated in science discussion rather than exploring and data collection.