10.2 Tripartite network analysis?
How to add the respective department of each class to the story?
classes_to_departments <- data.frame(class = c("Biostatistics","Islamic Civ", "Calc 1", "Linear Algebra", "Chemistry", "The Modern World-System", "Calc 2", "Social Networks", "Exile and Diaspora"), department = c("Math", "History", "Math", "Math", "Chemistry", "Sociology", "Math", "Sociology", "History"), stringsAsFactors = F)
classes_to_departments_matrix <- table(classes_to_departments)
class(classes_to_departments_matrix) <- "matrix" Now following the paper on tripartite structural analysis, we can multiply the transpose of this matrix by the transpose of classesMatrix to trace links between people and departments!
people_to_departments <- t(classes_to_departments_matrix) %*% t(classesMatrix)We can graph this matrix and analyze it like a bipartite graph.
people_to_departments %>%
graph.incidence() %>%
as_tbl_graph() %>%
ggraph( layout = 'kk') +
geom_edge_link() +
geom_node_label(aes(label = name, fill = type))
10.2.1 Lab
data(paper_authors)
data(authors)
data(papers)
papers <- papers %>%
filter(year >= 2016)
paper_authors <- paper_authors %>%
filter(paper %in% papers$paper)
paper_authors <- paper_authors %>%
mutate(author = authors$user_nber[match(paper_authors$author , authors$author)])paper_authors %>%
sjmisc::flat_table() %>%
graph.incidence() %>%
as_tbl_graph() %>%
ggraph( layout = 'kk') +
geom_edge_link() +
geom_node_poin()