I need to create a bipartite graph for consumer-brand relationships.
This is my example data:
datf <- data.frame(Consumers = c("A", "B", "C", "D", "E"),
Brands = c("Costa", "Starbucks", "Cafe2U", "Costa", "Costa"))
The following code gives me a network. But I am not sure how I can add a node type attribute to label consumers and brands:
library(igraph)
dat=read.csv(file.choose(),header=TRUE)
el=as.matrix(dat)
el[,1]=as.character(el[,1])
el[,2]=as.character(el[,2])
g=graph.edgelist(el,directed=FALSE)
I would like to create a bipartite graph with edges that connect each consumer with the brand they like. Ideally, the nodes will be labeled with text.
Could you show me how to do this using library(igraph)
?