#setwd("/cloud/project/Learning Analytics final project")Final Project: Independent Data Intensive Research
ETR537
Overview
As a final project, you’ll be applying the knowledge and skills gained throughout this semester to conduct the independent analysis. Similar to the case studies provided in this course, your analysis should demonstrate your ability to wrangle, analyze, and communicate findings in response to a research question of interest. You will also be expected to use Quarto to create a reproducible data product, which contains all the code used during each step of your analysis so it can be reproduced by others.
Grading Criteria
Grading criteria for your final project is guided by the Data-Intensive Research Workflow from Learning analytics goes to school: A collaborative approach to improving education (Krumm, Means, & Bienkowski, 2018).
Creating Local Environment
Importing Packages
library(readr)
library(dataedu)
library(tidyverse)Warning: package 'tidyverse' was built under R version 4.3.2
Warning: package 'ggplot2' was built under R version 4.3.2
Warning: package 'tidyr' was built under R version 4.3.2
Warning: package 'dplyr' was built under R version 4.3.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.3 ✔ purrr 1.0.1
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
── 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
library(tidytext)Warning: package 'tidytext' was built under R version 4.3.2
library(textdata)Warning: package 'textdata' was built under R version 4.3.2
library(here)Warning: package 'here' was built under R version 4.3.2
here() starts at C:/Users/Saura/OneDrive/Desktop/Learning anaytics final/LearningAnalytics/LA
library(ggplot2)
library(ggpubr)
library(tibble)
library(dplyr)
library(tidygraph)Warning: package 'tidygraph' was built under R version 4.3.2
Attaching package: 'tidygraph'
The following object is masked from 'package:stats':
filter
library(ggraph)Warning: package 'ggraph' was built under R version 4.3.2
Importing data to the environment
df <- read_csv("ngss-tweets.csv")Rows: 8125 Columns: 8
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): text, source
dbl (4): author_id, id, conversation_id, in_reply_to_user_id
lgl (1): possibly_sensitive
dttm (1): created_at
ℹ 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.
head(df)# A tibble: 6 × 8
text created_at author_id id conversation_id source
<chr> <dttm> <dbl> <dbl> <dbl> <chr>
1 "Please help us … 2021-01-06 00:50:49 3.28e 9 1.35e18 1.35e18 Twitt…
2 "What lab materi… 2021-01-06 00:45:32 1.01e18 1.35e18 1.35e18 Hoots…
3 "I recently saw … 2021-01-06 00:39:37 6.18e 7 1.35e18 1.35e18 Twitt…
4 "I'm thrilled to… 2021-01-06 00:30:13 4.62e 8 1.35e18 1.35e18 Twitt…
5 "PLS RT. Excited… 2021-01-06 00:15:05 2.23e 7 1.35e18 1.35e18 Twitt…
6 "Inspired by Mar… 2021-01-06 00:00:00 3.32e 9 1.35e18 1.35e18 Tweet…
# ℹ 2 more variables: possibly_sensitive <lgl>, in_reply_to_user_id <dbl>
Step 1: Prepare
Instructions:
Your data product should demonstrate your ability to formulate clear, actionable research questions relevant to a targeted audience. Specifically, your data product should include an introduction that:
Clearly describes the purpose of your data product, including the research question(s) guiding your analyses.
Platform Preference: What are the most commonly used platforms for participating in #ngssChat? This is indicated by the predominance of Twitter for iPhone, followed by other platforms like the Twitter Web App, TweetDeck, and Twitter for Android.
Engagement and Influence: Who are the most influential participants in the #ngssChat? This can be inferred from data like the author with auth_id 862286744 having the highest number of interactions.
Network Dynamics: What is the nature of the interaction among the participants? This is reflected in the number of unique tweet repliers (429) and creators (276), especially considering tweets with responses.
Content Analysis: What topics or themes are most prevalent in the #ngssChat discussions? The frequent mention of specific Twitter handles like @ngsschat and @ngsstweeps and tags like #NGSS suggests dominant themes or subtopics within the broader conversation.
Community Engagement: How extensive is the community engagement in the #ngssChat? This can be evaluated by examining the 2680 unique mentioned tweets and the 2708 unique tags used in the discussions.
By addressing these questions, the data product aims to provide a comprehensive overview of the #ngssChat Twitter community, highlighting key influencers, platforms, and topics of discussion. This could be valuable for educators and policy makers
----------
Provides information about the data sources, including the context in which the data was collected and variables used to address your research questions.
Research Question
“How do different stakeholders in the educational community engage, interact, and influence the discourse around the Next Generation Science Standards (NGSS) on Twitter, as evidenced by the #NGSSchat discussions?”
Data Sources and Context
Primary Data Source: The primary dataset consists of over 7,000 Twitter posts made by 276 individuals participating in the #NGSSchat discussions.
Additional Reference: The dataset was also utilized in Rosenberg (2020) project and provided for ETR 537 course at Northern Illinois University’s Blackboard platform, offering a context for educational research.
Variables Used
There were 8 variables represented in the dataset:
text”
“created_at”
“author_id”
“id”
“conversation_id”
“source”
“possibly_sensitive”
“in_reply_to_user_id” “tags”
Among them following were used-
Participant identifiers: Main identifiers used “author_id” and “in_reply_to_user_id” to gather user information
Platform Usage: Identification of platforms used (e.g., Twitter for iPhone, Twitter Web App) to understand technology preferences in participation. This data was found under the name of “source.”
Tweet text: Tweet text was used as well to analyze frequency of tags(#). Variable “text” was used for this purpose.
---------
Step 2: Wrangle
Your data project should demonstrate your ability to use R to manipulate, clean, transform, and/or merging data in order to prepare your text for analysis. Specifically, your data product should clearly describe:
Data preprocessing steps (e.g., renaming variables, filtering, tokenization, stemming, stop words removal, etc.) taken to clean and prepare your text for analysis and why are they necessary, as well as any steps will excluded and why.
Any new variables or features you created to address your research questions; or any data transformations you made required for the types of analyses or packages used (e.g. reshaping, merging, joining etc.).
glimpse(df) Rows: 8,125
Columns: 8
$ text <chr> "Please help us RT and consider donating to help r…
$ created_at <dttm> 2021-01-06 00:50:49, 2021-01-06 00:45:32, 2021-01…
$ author_id <dbl> 3.279908e+09, 1.010325e+18, 6.182965e+07, 4.616534…
$ id <dbl> 1.346620e+18, 1.346619e+18, 1.346617e+18, 1.346615…
$ conversation_id <dbl> 1.346620e+18, 1.346619e+18, 1.346617e+18, 1.346615…
$ source <chr> "Twitter for iPhone", "Hootsuite Inc.", "Twitter f…
$ possibly_sensitive <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, F…
$ in_reply_to_user_id <dbl> NA, NA, NA, NA, NA, NA, NA, 1.023054e+18, 4.918508…
colnames(df)[1] "text" "created_at" "author_id"
[4] "id" "conversation_id" "source"
[7] "possibly_sensitive" "in_reply_to_user_id"
- Creating new variable “all_mentions” : This variable is used to gather all mentions (@)
library(tidytext)
library(tidyverse)
library(dplyr)
library(tidyr)
regex <- "@([A-Za-z]+[A-Za-z0-9_]+)(?![A-Za-z0-9_]*\\.)"
data <-
df %>%
# Use regular expression to identify all the usernames in a tweet
mutate(all_mentions = str_extract_all(text, regex)) %>%
unnest(all_mentions)- Creating new variable “tags” : This variable is used to gather all tags (#)
library(tidytext)
library(tidyverse)
library(dplyr)
library(tidyr)
regex <- "#([A-Za-z]+[A-Za-z0-9_]+)(?![A-Za-z0-9_]*\\.)"
data <-
df %>%
# Use regular expression to identify all the usernames in a tweet
mutate(tags = str_extract_all(text, regex)) %>%
unnest(tags)- Creating mentions data set: Since I do not have the screen name of the authors. Therefore, I am using author_id here.
library(tidytext)
library(tidyverse)
library(dplyr)
library(tidyr)
regex <- "@([A-Za-z]+[A-Za-z0-9_]+)(?![A-Za-z0-9_]*\\.)"
data <-
df %>%
# Use regular expression to identify all the usernames in a tweet
mutate(all_mentions = str_extract_all(text, regex)) %>%
unnest(all_mentions)
#This chunk of code is copied from ETR-537 course by Dr. Cansu Tatar of NIU
library(dplyr)
mentions <-
data %>%
mutate(all_mentions = str_trim(all_mentions)) %>%
select(sender = author_id, all_mentions, in_reply_to_user_id)
mentions# A tibble: 11,771 × 3
sender all_mentions in_reply_to_user_id
<dbl> <chr> <dbl>
1 6.18e 7 @ngsnavigators NA
2 6.18e 7 @ngsnavigators NA
3 2.23e 7 @ngsnavigators NA
4 2.23e 7 @wandabryant NA
5 2.23e 7 @jengutierrez18 NA
6 2.23e 7 @NGSS_tweeps NA
7 2.23e 7 @CSSSupervisors NA
8 1.02e18 @NGSS_tweeps 1.02e18
9 1.02e18 @NGSS_tweeps 4.92e 9
10 2.37e 7 @calwater NA
# ℹ 11,761 more rows
- Creating Edgelist: Let’s remove that “@” symbol from the columns we created and save the results to a new tibble,
edgelist
#This chunk of code is copied from ETR-537 course by Dr. Cansu Tatar of NIU
edgelist <-
mentions %>%
# remove "@" from all_mentions column
mutate(all_mentions = str_sub(all_mentions, start = 2)) %>%
# rename all_mentions to receiver
select(sender, receiver = in_reply_to_user_id, all_mentions)
edgelist# A tibble: 11,771 × 3
sender receiver all_mentions
<dbl> <dbl> <chr>
1 6.18e 7 NA ngsnavigators
2 6.18e 7 NA ngsnavigators
3 2.23e 7 NA ngsnavigators
4 2.23e 7 NA wandabryant
5 2.23e 7 NA jengutierrez18
6 2.23e 7 NA NGSS_tweeps
7 2.23e 7 NA CSSSupervisors
8 1.02e18 1.02e18 NGSS_tweeps
9 1.02e18 4.92e 9 NGSS_tweeps
10 2.37e 7 NA calwater
# ℹ 11,761 more rows
Now lets remove all missing values from edgelist
edgelist <- na.omit(edgelist)
edgelist# A tibble: 7,630 × 3
sender receiver all_mentions
<dbl> <dbl> <chr>
1 1.02e18 1.02e18 NGSS_tweeps
2 1.02e18 4.92e 9 NGSS_tweeps
3 1.56e 9 4.92e 9 NGSS_tweeps
4 1.21e18 4.92e 9 NGSS_tweeps
5 2.61e 8 4.92e 9 NGSS_tweeps
6 2.20e 9 3.30e 9 airmelia
7 2.20e 9 3.30e 9 lolitalitaah
8 2.61e 8 4.92e 9 NGSS_tweeps
9 3.30e 9 2.20e 9 Createxx93
10 3.30e 9 2.20e 9 lolitalitaah
# ℹ 7,620 more rows
Step 3 & 4: Analyze (Model and Explore)
Your data project should demonstrate your ability to use R to apply text mining techniques appropriate to your research questions and data sources. Specifically, your data product should clearly include:
Clear descriptions of the techniques (e.g., descriptive statistics, network analysis, sentiment analysis, etc.) you applied to analyze your data.
Interpretations/meanings of specific metrics (e.g., counts, means, proportions, sentiment values, centrality measures, etc.) that your analysis generated.
Descriptive Statistics:
1) I am interested to learn about frequencies of the sources of origination of tweets with the #ngssChat. Therefore, first I need to know how many unique sources are there.
length (unique(df$source))[1] 642) There are 33 unique sources of #ngssChat. Now I need to know who are top 10 among those sources. These are measured in counts.
SourceTable = sort(table(data$source), decreasing=TRUE)[1:10] SourceTable <- data.frame(SourceTable) SourceTableVar1 Freq 1 Twitter for iPhone 4796 2 Twitter Web App 3837 3 TweetDeck 1339 4 Twitter for Android 1242 5 Twitter for iPad 312 6 Hootsuite Inc. 72 7 Sprout Social 24 8 Buffer 23 9 IFTTT 22 10 Paper.li 22
3) I am interested in number of unique mentions in the twitter.
length (unique(data$all_mentions))[1] 2680
4) Now, I need to know what are top 10 of them in frequency count
MentionTable = sort(table(data$all_mentions), decreasing=TRUE)[1:10]
MentionTable <- data.frame(MentionTable)
MentionTable Var1 Freq
1 @NGSS_tweeps 1564
2 @NGSSchat 201
3 @OpenSciEd 179
4 @TedWillard2061 151
5 @NSTA 150
6 @BMSscienceteach 122
7 @sbottasullivan 114
8 @thinksci 114
9 @philiplbell 113
10 @KRenaeP 109
Network Analysis:
Network analysis is a technique employed to examine the relationships and interactions within networks, composed of nodes (participants or groups) and links (their connections or exchanges). Applied to the #NGSSchat study, Rosenberg(2020) scrutinizes over 7,000 Twitter posts to analyze the interaction patterns among educators, administrators, researchers, and various organizations. This approach helps in identifying communication patterns, key influencers, and the level of collaboration among different educational roles. It offers a deeper understanding of the nature, balance, and substance of discussions, shedding light on the role these interactions play in advancing educational reforms like the NGSS. Here I will also follow the same method on 71457 tweets to visualize the connected users.
Lets First count the number of interactions sent by each senders
#This chunk of code is copied from ETR-537 course by Dr. Cansu Tatar of NIU
interactions_sent <- edgelist %>%
# this counts how many times each sender appears in the data frame, effectively counting how many interactions each individual sent
count(sender) %>%
# arranges the data frame in descending order of the number of interactions sent
arrange(desc(n))
interactions_sent# A tibble: 748 × 2
sender n
<dbl> <int>
1 8.73e 8 259
2 8.62e 8 224
3 2.56e 8 182
4 1.64e 7 177
5 5.59e 8 172
6 1.45e 9 157
7 1.85e 8 135
8 3.16e 9 129
9 3.10e 9 116
10 1.33e18 114
# ℹ 738 more rows
To plot a prominent map and thin-out less active users lets filter out the tweets that have a frequency of less than 1.
#This chunk of code is copied from ETR-537 course by Dr. Cansu Tatar of NIU
interactions_sent <-
interactions_sent %>%
filter(n > 1)
interactions_sent# A tibble: 560 × 2
sender n
<dbl> <int>
1 8.73e 8 259
2 8.62e 8 224
3 2.56e 8 182
4 1.64e 7 177
5 5.59e 8 172
6 1.45e 9 157
7 1.85e 8 135
8 3.16e 9 129
9 3.10e 9 116
10 1.33e18 114
# ℹ 550 more rows
following code shows edgeilst without emails from sender to same sender
#This chunk of code is copied from ETR-537 course by Dr. Cansu Tatar of NIU
edgelist_unique <- edgelist %>%
filter(sender %in% interactions_sent$sender,
receiver %in% interactions_sent$sender)
edgelist_unique# A tibble: 6,299 × 3
sender receiver all_mentions
<dbl> <dbl> <chr>
1 1.02e18 1.02e18 NGSS_tweeps
2 1.02e18 4.92e 9 NGSS_tweeps
3 1.56e 9 4.92e 9 NGSS_tweeps
4 1.21e18 4.92e 9 NGSS_tweeps
5 2.61e 8 4.92e 9 NGSS_tweeps
6 2.20e 9 3.30e 9 airmelia
7 2.20e 9 3.30e 9 lolitalitaah
8 2.61e 8 4.92e 9 NGSS_tweeps
9 3.30e 9 2.20e 9 Createxx93
10 3.30e 9 2.20e 9 lolitalitaah
# ℹ 6,289 more rows
Now calculate number of unique replyers:
length(unique(edgelist_unique$sender))[1] 429
Now calculate number of unique twit senders:
length(unique(edgelist_unique$receiver))[1] 276
6) Let us see the number of unique tags in the tweets
length(unique(data$tags))Warning: Unknown or uninitialised column: `tags`.
[1] 0
7) What are most frequent tags
tagTable = sort(table(data$tags), decreasing=TRUE)[1:10]Warning: Unknown or uninitialised column: `tags`.
tagTable <- data.frame(tagTable)
tagTable tagTable
1 NA
2 NA
3 NA
4 NA
5 NA
6 NA
7 NA
8 NA
9 NA
10 NA
----------
- Data visualizations that are attractive and easy to interpret, and include text or narrative for aiding their Interpretation by others.
a) Source of Tweet: Following bar diagram shows number of tweets originated from sources.
theme_set(theme_pubr())
ggplot(data = SourceTable, aes(x=SourceTable$Var1, y= SourceTable$Freq)) + geom_bar(stat="identity")+
labs_pubr()+
coord_flip()+
labs(x = "Top 10 Sources", y = "frequency")Warning: Use of `SourceTable$Var1` is discouraged.
ℹ Use `Var1` instead.
Warning: Use of `SourceTable$Freq` is discouraged.
ℹ Use `Freq` instead.
b)Top mentions:
theme_set(theme_pubr())
ggplot(data = MentionTable, aes(x=MentionTable$Var1, y= MentionTable$Freq)) + geom_bar(stat="identity")+
labs_pubr()+
coord_flip()+
labs(x = "Top 10 Mention", y = "frequency")Warning: Use of `MentionTable$Var1` is discouraged.
ℹ Use `Var1` instead.
Warning: Use of `MentionTable$Freq` is discouraged.
ℹ Use `Freq` instead.
C) Social Network
g <-
as_tbl_graph(edgelist_unique)
g# A tbl_graph: 438 nodes and 6299 edges
#
# A directed multigraph with 38 components
#
# A tibble: 438 × 1
name
<chr>
1 1023054370529857536
2 1555906686
3 1211837761444954112
4 260773268
5 2198414407
6 3296431010
# ℹ 432 more rows
#
# A tibble: 6,299 × 3
from to all_mentions
<int> <int> <chr>
1 1 1 NGSS_tweeps
2 1 21 NGSS_tweeps
3 2 21 NGSS_tweeps
# ℹ 6,296 more rows
network <- g %>%
# we chose the kk layout as it created a graph which was easy-to-interpret, but others are available; see ?ggraph
ggraph(layout = "kk") +
# this adds the points to the graph
geom_node_point() +
# this adds the links, or the edges; alpha = .2 makes it so that the lines are partially transparent
geom_edge_link(alpha = .2) +
# this last line of code adds a ggplot2 theme suitable for network graphs
labs_pubr()+
theme_graph()
networkWarning: 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.
To visualize better:
g %>%
# this calculates the centrality of each individual using the built-in centrality_authority() function
mutate(centrality = centrality_authority()) %>%
ggraph(layout = "kk") +
geom_node_point(aes(size = centrality, color = centrality)) +
# this line colors the points based upon their centrality
scale_color_continuous(guide = 'legend') +
geom_edge_link(alpha = .2)Now, to create visualization better lets have interaction set value greater than 50 tweets instead of 1.
library(igraph)Warning: package 'igraph' was built under R version 4.3.2
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
interactions_sent50 <-
interactions_sent %>%
filter(n > 50)
edgelist_unique50 <- edgelist %>%
filter(sender %in% interactions_sent50$sender,
receiver %in% interactions_sent50$sender)
g50 <-
as_tbl_graph(edgelist_unique50)
network50 <- g50 %>%
# we chose the kk layout as it created a graph which was easy-to-interpret, but others are available; see ?ggraph
ggraph(layout = "kk") +
# this adds the points to the graph
geom_node_point() +
# this adds the links, or the edges; alpha = .2 makes it so that the lines are partially transparent
geom_edge_link(alpha = .2) +
# this last line of code adds a ggplot2 theme suitable for network graphs
labs_pubr()+
theme_graph()
network50g50 %>%
# this calculates the centrality of each individual using the built-in centrality_authority() function
mutate(centrality = centrality_authority()) %>%
ggraph(layout = "kk") +
geom_node_point(aes(size = centrality, color = centrality)) +
geom_node_text(aes(label = name), vjust = 1.5, hjust = 0.5)+
# this line colors the points based upon their centrality
scale_color_continuous(guide = 'legend') +
geom_edge_link(alpha = .2)From the above network we can figure out which author have highest level of interaction.
d) Tags in a tweet : Following bar diagram shows number of times a tag was used
library(tidytext)
library(tidyverse)
library(dplyr)
library(tidyr)
regex <- "#([A-Za-z]+[A-Za-z0-9_]+)(?![A-Za-z0-9_]*\\.)"
data <-
df %>%
# Use regular expression to identify all the usernames in a tweet
mutate(tags = str_extract_all(text, regex)) %>%
unnest(tags)
tagTable = sort(table(data$tags), decreasing=TRUE)[1:10]
tagTable <-data.frame(tagTable)
library(ggplot2)
theme_set(theme_pubr())
ggplot(data = tagTable, aes(x=Var1, y= Freq)) + geom_bar(stat="identity")+
labs_pubr()+
coord_flip()+
labs(x = "Top 10 tags", y = "frequency")Step 5: Communication
Your data product should demonstrate your ability to clearly and effectively communicate the most important and most useful findings. Specifically, your data product should:
- Highlights key finding and insights in response to your research questions.
---------------
Findings:
There are 33 total sources of origination of #ngssChat in the Twitter. Twitter for iPhone is the highest among them, Followed by Twitter Web App, TwittDeck, and Twitter for Android.
There are 2680 unique mentioned tweeds are there and among them @ngsschat and @ngsstweeps are most common.
Number of unique twitt replier is 429 and number of unique twit creator is 276, when all the twitt with no replies are removed.
Author with auth_id 862286744 has highest number of interactions.
Let us see the number of unique tags in the tweets 2708
What are most frequent tags #NGCSS
-------
- Suggests potential action that you and/or your target audience to better understand and improve the context in which your data product is intended to inform.
To enhance the #NGSSchat network, it’s crucial to engage with highly interactive users like the one with auth_id 862286744, who are key in spreading insights and fostering discussions. Optimizing content for mobile users, particularly for Twitter for iPhone, and understanding the functionalities of platforms like Twitter Web App and TweetDeck can improve communication strategies. Additionally, focusing on prominent accounts like @ngsschat and @ngsstweeps and frequently used tags like #NGSS can extend reach and foster collaborative discussions.
----------
- Discusses the limitations and any ethical/legal issues taken into consideration, including acknowledgments any reference materials used.
The study’s limitations include potential bias in user representation and the generalizability of findings beyond the #NGSSchat community. Ethical considerations involved ensuring user privacy and data confidentiality. Legal issues included adhering to Twitter’s terms of use regarding data collection and analysis. Acknowledgments extend to all reference materials and methodologies utilized, ensuring transparency and integrity in the research process.
References
Rosenberg, J. M., Reid, J. W., Dyer, E. B., J Koehler, M., Fischer, C., & McKenna, T. J. (2020). Idle chatter or compelling conversation? The potential of the social media‐based# NGSSchat network for supporting science education reform efforts. Journal of Research in Science Teaching, 57(9), 1322-1355.