I am interested in conducting a network analysis using data I have on national energy projects. In particular, I would like to construct a bipartite network, where one type of nodes include individual companies (for example "national utility 1") and another set of nodes include individual energy projects (such as a 200 MW wind farm OR 30 a MW solar park etc.).
I am new to SNA/working in R, so apologies if my question is rather basic...
At present I have used the KATETO bipartite igraph tutorial (beginning at p. 12, available here: https://kateto.net/network-visualization) for setting up the basic network configuration. The step-by-step procedure follows below.
Setup
<setwd("C:/Users/u0141797/Desktop/Data files")>
<install.packages("igraph")>
<library("igraph")>
Upload the data:
<nodes2 <- read.csv("C:/Users/u0141797/Desktop/Data files/Dataset2-Investment-User-Example-NODES.csv", header=T, as.is=T)>
<links2 <- read.csv("C:/Users/u0141797/Desktop/Data files/Dataset2-Investment-User-Example-EDGES.csv", header=T, row.names=1)>
#The first file is a node list with relevant attributes (companies as shown in screenshot 1, then individual projects further down the list is shown in screenshot 2). The second file as adjacency matrix, indicating relationships between both types of nodes (companies and projects) in my two mode network.
[CSV node list part 1](https://i.stack.imgur.com/iyP3a.png)
[CSV node list part 2](https://i.stack.imgur.com/zb6JM.png)
[CSV adjacency matricx](https://i.stack.imgur.com/xMPog.png)
Examine the data and create an igraph object
<head(links2)>
`P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 C1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C2 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C3 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C4 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C5 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C6 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<links2 <- as.matrix(links2)>
<dim(links2)>
[1] 39 55
<dim(nodes2)>
[1] 94 5
<net2 <- graph_from_incidence_matrix(links2)>
<table(V(net2)$type)>
FALSE TRUE 39 55
<plot(net2,vertex.label=NA)>
<net2>
IGRAPH f9462e2 UN-B 94 54 --
- attr: type (v/l), name (v/c)
- edges from f9462e2 (vertex names): [1] C1 --P1 C2 --P2 C2 --P8 C3 --P3 C3 --P4 C4 --P5 C5 --P6 C6 --P7 C6 --P31 C7 --P9 [11] C8 --P10 C9 --P11 C9 --P32 C9 --P49 C10--P12 C11--P13 C12--P14 C13--P15 C14--P16 C15--P17 [21] C16--P18 C17--P19 C17--P28 C17--P30 C17--P34 C17--P35 C17--P37 C17--P41 C18--P20 C18--P52 [31] C19--P21 C19--P29 C20--P23 C21--P24 C22--P25 C22--P33 C22--P50 C23--P26 C24--P27 C25--P36 [41] C26--P38 C27--P39 C28--P40 C29--P42 C30--P43 C31--P44 C32--P45 C33--P46 C34--P47 C35--P48 [51] C36--P51 C37--P53 C38--P54 C39--P55
Adjust node attributes; i.e. companies are blue squares, projects are orange circles (from p. 35 onwards)
<V(net2)$color <- c("steel blue", "orange")[V(net2)$type+1]>
<V(net2)$shape <- c("square", "circle")[V(net2)$type+1]>
<V(net2)$label <- ""`>
<V(net2)$label[V(net2)$type==F] <- nodes2$company[V(net2)$type==F]>
<V(net2)$label.cex=.6>
<V(net2)$label.font=2>
<plot(net2, vertex.label.color="white", vertex.size=(2-V(net2)$type)*8) >
Adjust node attributes; i.e. projects are given different colors by type (from p. 16 onwards)
<colrs <- c("gray50", "tomato", "gold", "black", "orange", "purple", "green","white")>
<V(net2)$color <- colrs[V(net2)$project.type]>
<Error in vattrs[[name]][index] <- value : replacement has length zero>
I am unable to proceed with attributing different node colors by 'project type', as indicated in the CSV node list. I would also like to size each project according to the 'project size' value in the same file. I have tried a few different solutions to overcome these issues but I have not resolved it yet. I think it might be made more difficult by the fact that the graph is two mode/bipartite, but I am not sure... One option could be to try another software (Gephi) or present make the network as one mode. However, I think it is more appealing to study both projects AND companies, rather than to only account for projects...but I am not sure.
Any help is greatly appreciated. Again, apologies for my noob ways.