I am working on a network graph using a .csv database containing companies and projects. I can make network graphs showing how all these companies are connected through their projects (one company works on several projects). My .csv database looks like this:
ProjectName | CompanyName | Year |
---|---|---|
Project 1 | Company A | 2020 |
Project 1 | Company B | 2020 |
Project 1 | Company C | 2020 |
Project 2 | Company A | 2021 |
Project 2 | Company C | 2021 |
Project 2 | Company D | 2021 |
I am using a conversion to matrix and matrix multiplication to generate an adjacency graph, but using this conversion the year column is lost (I cut it off on import). How can I make a network graph connecting companies working together, with colored edges showing the project years (2 blocks of 4 years) in which they cooperate?
I currently use this for a 'normal' network plot containing all years:
twomode_edgelist<- read.csv("database.csv", header=T, sep = ";", colClasses=c(NA,NA,"NULL")
twomode_table <- table(twomode_edgelist)
twomode_matrix <- as.matrix(twomode_table)
onemode <- as.matrix (t(twomode_matrix) %*% twomode_matrix)
diag(onemode) <- 0
g <- graph.adjacency(onemode1, mode=c("undirected"), weighted=TRUE)
plot(g)
Thanks a lot for thinking with me, I have never used R before and making the first graph took me way to much time!