0

I have a table made with two lists A and B of individuals and their relationship R that can either take the values of 0, 1, or 2.

I want to create a graph where I have the list A on one side, the list B on the other side and items on both lists linked together with a different color depending on the value of R.

Any idea or suggestion on how to do it much appreciated!

So the data looks something like :

A, B, R
A1, B1, 0
A1, B2, 2
A1, B3, 0
A2, B1, 1
A2, B2, 0
A2, B3, 1
A3, B1, 0
A3, B2, 0
A3, B3, 2
zx8754
  • 52,746
  • 12
  • 114
  • 209
ocuti
  • 1
  • 2

1 Answers1

1
plot(igraph::graph_from_data_frame(df, FALSE),
     edge.color = df$R + 1,
     layout = as.matrix(rev(expand.grid(1:3, 1:2))))

enter image description here

Onyambu
  • 67,392
  • 3
  • 24
  • 53