+ - 0:00:00
Notes for current slide
Notes for next slide

Part 3: Network Description

#aectRTD workshop

K. Bret Staudt Willet | Florida State University

March 4, 2022

1 / 40



Workshop Information

2 / 40

Important Links

Homebase

Agenda

Help

3 / 40



Part 3:
Network Description

4 / 40

Useful R packages

5 / 40

Useful R packages

5 / 40

Useful R packages

5 / 40

Useful R packages

5 / 40



Network
Example 1

6 / 40

Network Example 1

Discussion Social Network Analysis: GitHub repository from @meteakca

7 / 40

Network Example 1

Discussion Social Network Analysis: GitHub repository from @meteakca

What do you think this code will do?

edgelist1 <-
read_csv("data/meteakca_edgelist.csv",
show_col_types = FALSE) %>%
mutate(group = week,
week = substr(week, 1, 1)
) %>%
group_by(from, to) %>%
mutate(weight = n())
glimpse(edgelist1)
7 / 40

Network Example 1

Discussion Social Network Analysis: GitHub repository from @meteakca

Let's see!

edgelist1 <-
read_csv("data/meteakca_edgelist.csv",
show_col_types = FALSE) %>%
mutate(group = week,
week = substr(week, 1, 1)
) %>%
group_by(from, to) %>%
mutate(weight = n()) %>%
distinct(from, to, weight)
glimpse(edgelist1)
## Rows: 182
## Columns: 3
## Groups: from, to [182]
## $ from <chr> "AL", "VW", "RN", "CH", "KW", "KJ", "Kwi", "AM", "KW", "KW", "Z…
## $ to <chr> "RN", "RN", "KW", "RN", "CH", "CH", "CH", "KW", "AM", "AL", "AL…
## $ weight <int> 1, 1, 1, 1, 2, 3, 1, 2, 2, 2, 1, 2, 1, 1, 1, 3, 1, 2, 1, 1, 1, …
8 / 40

Network Example 1

head(edgelist1, 15)
## # A tibble: 15 × 3
## # Groups: from, to [15]
## from to weight
## <chr> <chr> <int>
## 1 AL RN 1
## 2 VW RN 1
## 3 RN KW 1
## 4 CH RN 1
## 5 KW CH 2
## 6 KJ CH 3
## 7 Kwi CH 1
## 8 AM KW 2
## 9 KW AM 2
## 10 KW AL 2
## 11 ZT AL 1
## 12 LW AL 2
## 13 RS AL 1
## 14 SP AL 1
## 15 JK AL 1
9 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23
10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

  • Diameter: igraph::diameter(graph1) = 4

10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

  • Diameter: igraph::diameter(graph1) = 4

  • Density: igraph::edge_density(graph1) = 0.36

10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

  • Diameter: igraph::diameter(graph1) = 4

  • Density: igraph::edge_density(graph1) = 0.36

  • Node degree: igraph::degree(graph1, mode = 'all') = 15

10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

  • Diameter: igraph::diameter(graph1) = 4

  • Density: igraph::edge_density(graph1) = 0.36

  • Node degree: igraph::degree(graph1, mode = 'all') = 15

    • In-degree: igraph::degree(graph1, mode = 'in') = 8
10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

  • Diameter: igraph::diameter(graph1) = 4

  • Density: igraph::edge_density(graph1) = 0.36

  • Node degree: igraph::degree(graph1, mode = 'all') = 15

    • In-degree: igraph::degree(graph1, mode = 'in') = 8

    • Out-degree: igraph::degree(graph1, mode = 'out') = 8

10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

  • Diameter: igraph::diameter(graph1) = 4

  • Density: igraph::edge_density(graph1) = 0.36

  • Node degree: igraph::degree(graph1, mode = 'all') = 15

    • In-degree: igraph::degree(graph1, mode = 'in') = 8

    • Out-degree: igraph::degree(graph1, mode = 'out') = 8

  • Reciprocity: igraph::reciprocity(graph1) = 0.663

10 / 40

Network Example 1

graph1 <- tidygraph::as_tbl_graph(edgelist1)
  • Order: igraph::gorder(graph1) = 23

  • Size: igraph::gsize(graph1) = 182

  • Diameter: igraph::diameter(graph1) = 4

  • Density: igraph::edge_density(graph1) = 0.36

  • Node degree: igraph::degree(graph1, mode = 'all') = 15

    • In-degree: igraph::degree(graph1, mode = 'in') = 8

    • Out-degree: igraph::degree(graph1, mode = 'out') = 8

  • Reciprocity: igraph::reciprocity(graph1) = 0.663

  • Transitivity: igraph::transitivity(graph1) = 0.653

10 / 40

Network Example 1

What do you think this code will do?

sociogram1 <-
graph1 %>%
mutate(popularity = centrality_degree(mode = 'in')) %>%
ggraph(layout = 'kk') +
geom_edge_arc(alpha = .2,
width = .5,
strength = .5,
color = 'steelblue'
) +
geom_node_point(alpha = .4, aes(size = popularity)) +
scale_size(range = c(1,10)) +
theme_wsj() +
scale_colour_wsj("colors6") +
theme(axis.line=element_blank(),
axis.text.x=element_blank(), axis.text.y=element_blank(),
axis.ticks.x =element_blank(), axis.ticks.y =element_blank(),
axis.title.x=element_blank(), axis.title.y=element_blank(),
panel.background=element_blank(), panel.border=element_blank(),
panel.grid.major=element_blank(), panel.grid.minor=element_blank())
11 / 40

Network Example 1

Let's see!

sociogram1 <-
graph1 %>%
mutate(popularity = centrality_degree(mode = 'in')) %>%
ggraph(layout = 'kk') +
geom_edge_arc(alpha = .2,
width = .5,
strength = .5,
color = 'steelblue'
) +
geom_node_point(alpha = .4, aes(size = popularity)) +
scale_size(range = c(1,10)) +
theme_wsj() +
scale_colour_wsj("colors6") +
theme(axis.line=element_blank(),
axis.text.x=element_blank(), axis.text.y=element_blank(),
axis.ticks.x =element_blank(), axis.ticks.y =element_blank(),
axis.title.x=element_blank(), axis.title.y=element_blank(),
panel.background=element_blank(), panel.border=element_blank(),
panel.grid.major=element_blank(), panel.grid.minor=element_blank())
12 / 40

Network Example 1

13 / 40

Network Example 1

Next step: Look at the network by group or by week

13 / 40



Network
Example 2

14 / 40

Network Example 2

Article: A social network perspective on peer supported learning in MOOCs for educators (Kellogg, Booth, & Oliver, 2014)

15 / 40

Network Example 2

17 / 40

Network Example 2

What do you think this code will do?

edgelist2 <-
read_csv("data/DLT1 Edgelist.csv",
show_col_types = FALSE) %>%
group_by(Sender, Receiver) %>%
mutate(Weight = n()) %>%
ungroup() %>%
relocate(Sender, Receiver, Weight)
glimpse(edgelist2)
18 / 40

Network Example 2

Let's see!

edgelist2 <-
read_csv("data/DLT1 Edgelist.csv",
show_col_types = FALSE) %>%
group_by(Sender, Receiver) %>%
mutate(Weight = n()) %>%
distinct(Sender, Receiver, Weight)
glimpse(edgelist2)
## Rows: 1,978
## Columns: 3
## Groups: Sender, Receiver [1,978]
## $ Sender <dbl> 360, 356, 344, 392, 219, 318, 4, 355, 355, 310, 248, 150, 19,…
## $ Receiver <dbl> 444, 444, 444, 444, 444, 444, 444, 356, 444, 444, 444, 444, 3…
## $ Weight <int> 1, 2, 1, 1, 3, 2, 4, 1, 2, 1, 1, 2, 1, 1, 7, 1, 3, 1, 2, 1, 1…
19 / 40

Network Example 2

head(edgelist2, 15)
## # A tibble: 15 × 3
## # Groups: Sender, Receiver [15]
## Sender Receiver Weight
## <dbl> <dbl> <int>
## 1 360 444 1
## 2 356 444 2
## 3 344 444 1
## 4 392 444 1
## 5 219 444 3
## 6 318 444 2
## 7 4 444 4
## 8 355 356 1
## 9 355 444 2
## 10 310 444 1
## 11 248 444 1
## 12 150 444 2
## 13 19 310 1
## 14 216 19 1
## 15 19 444 7
20 / 40

Network Example 2

graph2 <- tidygraph::as_tbl_graph(edgelist2)
  • Order: igraph::gorder(graph2) = 442

  • Size: igraph::gsize(graph2) = 1978

  • Diameter: igraph::diameter(graph2) = 8

  • Density: igraph::edge_density(graph2) = 0.01

  • Node degree: igraph::degree(graph2, mode = 'all') = 4

    • In-degree: igraph::degree(graph2, mode = 'in') = 1

    • Out-degree: igraph::degree(graph2, mode = 'out') = 2

  • Reciprocity: igraph::reciprocity(graph2) = 0.219

  • Transitivity: igraph::transitivity(graph2) = 0.089

21 / 40

Network Example 2

sociogram2 <-
graph2 %>%
mutate(popularity = centrality_degree(mode = 'in')) %>%
ggraph(layout = 'kk') +
geom_edge_arc(alpha = .2,
width = .5,
strength = .5,
color = 'steelblue'
) +
geom_node_point(alpha = .4, aes(size = popularity)) +
scale_size(range = c(1,10)) +
theme_wsj() +
scale_colour_wsj("colors6") +
theme(axis.line=element_blank(),
axis.text.x=element_blank(), axis.text.y=element_blank(),
axis.ticks.x =element_blank(), axis.ticks.y =element_blank(),
axis.title.x=element_blank(), axis.title.y=element_blank(),
panel.background=element_blank(), panel.border=element_blank(),
panel.grid.major=element_blank(), panel.grid.minor=element_blank())
22 / 40

Network Example 2

23 / 40



Network
Example 3

24 / 40

Network Example 3

R package demo: Using tidytags with a conference hashtag (Staudt Willet & Rosenberg, 2022)

25 / 40

Network Example 3

What do you think this code will do?

google_sheet_url <- "18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8"
google_sheet_data <-
google_sheet_url %>%
tidytags::read_tags()
extra_tweet_data <-
tidytags::pull_tweet_data(google_sheet_data) %>%
tidytags::process_tweets()
edgelist3 <-
tidytags::create_edgelist(extra_tweet_data) %>%
group_by(sender, receiver) %>%
mutate(weight = n()) %>%
distinct(sender, receiver, weight)
write_csv(edgelist3, "data/tidytags-edgelist.csv")
26 / 40

Network Example 3

Let's see!

edgelist3 <-
read_csv("data/tidytags-edgelist.csv",
show_col_types = FALSE)
glimpse(edgelist3)
## Rows: 1,577
## Columns: 3
## $ sender <chr> "lbukunAA", "bretsw", "bretsw", "bretsw", "AECT", "correia65"…
## $ receiver <chr> "lbukunAA", "bretsw", "eromerohall", "FakeBobGagne", "jmenglu…
## $ weight <dbl> 1, 6, 3, 4, 2, 6, 6, 6, 6, 2, 7, 2, 15, 2, 2, 4, 18, 8, 2, 6,…
27 / 40

Network Example 3

head(edgelist3, 15)
## # A tibble: 15 × 3
## sender receiver weight
## <chr> <chr> <dbl>
## 1 lbukunAA lbukunAA 1
## 2 bretsw bretsw 6
## 3 bretsw eromerohall 3
## 4 bretsw FakeBobGagne 4
## 5 AECT jmenglund03 2
## 6 correia65 AnnaRoseLeach 6
## 7 caranorth11 FredWBaker 6
## 8 PaulineMuljana tintinluo 6
## 9 PaulineMuljana AmyLomellini_ID 6
## 10 PaulineMuljana WEHSLibrary 2
## 11 PaulineMuljana robmoore3 7
## 12 PaulineMuljana soniastic 2
## 13 nicolapallitt aectclt 15
## 14 nicolapallitt eromerohall 2
## 15 michaelmgrant FakeBobGagne 2
28 / 40

Network Example 3

graph3 <- tidygraph::as_tbl_graph(edgelist3)
  • Order: igraph::gorder(graph3) = 511

  • Size: igraph::gsize(graph3) = 1577

  • Diameter: igraph::diameter(graph3) = 23

  • Density: igraph::edge_density(graph3) = 0.006

  • Node degree: igraph::degree(graph3, mode = 'all') = 2

    • In-degree: igraph::degree(graph3, mode = 'in') = 1

    • Out-degree: igraph::degree(graph3, mode = 'out') = 1

  • Reciprocity: igraph::reciprocity(graph3) = 0.263

  • Transitivity: igraph::transitivity(graph3) = 0.09

29 / 40

Network Example 3

sociogram3 <-
graph3 %>%
mutate(popularity = centrality_degree(mode = 'in')) %>%
ggraph(layout = 'kk') +
geom_edge_arc(alpha = .2,
width = .5,
strength = .5,
color = 'steelblue'
) +
geom_node_point(alpha = .4, aes(size = popularity)) +
scale_size(range = c(1,10)) +
theme_wsj() +
scale_colour_wsj("colors6") +
theme(axis.line=element_blank(),
axis.text.x=element_blank(), axis.text.y=element_blank(),
axis.ticks.x =element_blank(), axis.ticks.y =element_blank(),
axis.title.x=element_blank(), axis.title.y=element_blank(),
panel.background=element_blank(), panel.border=element_blank(),
panel.grid.major=element_blank(), panel.grid.minor=element_blank())
30 / 40

Network Example 3

31 / 40



Network
Comparing networks

32 / 40

Comparing networks

33 / 40

Comparing networks

Variable Classroom MOOC Twitter
Order 23.000 442.000 511.000
Size 182.000 1978.000 1577.000
Diameter 4.000 8.000 23.000
Density 0.360 0.010 0.006
Median Degree 15.000 4.000 2.000
In-Degree 8.000 1.000 1.000
Out-Degree 8.000 2.000 1.000
Reciprocity 0.663 0.219 0.263
Transitivity 0.653 0.089 0.090
34 / 40



Try it out!

Hop over to Workspace 3

35 / 40



Quick Check In

(Five minutes in groups, five minutes together)

  • What challenges did you encounter?
  • What successes did you have?
  • What questions remain?
36 / 40



Appendix:
Helpful Resources
and Troubleshooting

37 / 40

Resources

Beginners:

Intermediates:

Experts:

38 / 40

Troubleshooting

  • Try to find out what the specific problem is
    • Identify what is not causing the problem
  • "Unplug and plug it back in" - restart R; close and reopen R
  • Seek out workshops and other learning opportunities
  • Reach out to others! Sharing what is causing an issue can often help to clarify the problem
  • General strategies on learning more: Chapter 17 of Data Science in Education Using R
39 / 40



Next up
Part 4:
Network Inference

Part 4 slide deck here

40 / 40



Workshop Information

2 / 40
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow