title: Correctly color vertices in R igraph
body: <p>I am using igraph to color vertices</p>
  
  <p>I have two CSV files answers and topology of the graph.</p>
  
  <p>Answers: (this tells that players K and N answered correctly)</p>
  
  <pre><code>  Player Q1_I1
  1      k     1
  2      l     0
  3      n     1
  4      m     0
  </code></pre>
  
  <p>Topology: (representation of who is connected to whom)</p>
  
  <pre><code>  Node.1 Node.2
  1      k      l
  2      l      k
  3      l      m
  4      m      l
  5      l      n
  6      n      l
  7      n      k
  8      k      n
  </code></pre>
  
  <p>I wanted to build a graph using package IGraph and to color vertices in different colors depending of their correctness.</p>
  
  <p>This is what I was able to achieve:</p>
  
  <pre><code># reads answers and creates a graph from topology
  answers &lt;- read.csv("answers2.csv",header=T)
  data&lt;-read.csv('edges2.csv')
  data&lt;-graph.data.frame(data1, directed=FALSE)
  g&lt;-simplify(data)
  
  # goes through vertices and colors them in different color, depending on correctness. 
  # 2 means second column (First one is the players name)
  V(g)$color &lt;- ifelse(answers[V(g), 2] == 1, "blue", "red")
  plot(g, layout=layout.fruchterman.reingold, vertex.color=V(g)$color)  
  </code></pre>
  
  <p>The problem is that in my output the colors are wrong:<img src="https://i.stack.imgur.com/OFOzr.png" alt="enter image description here"></p>
  
  <p>Here M and K are marked as correct, whereas it should be N and K.
  I think that the problem is because I am not specifying that Node should be related to Player, and I tried to achieve this, but with no success.</p>
  
  <p>Are there any ideas how to achieve this?</p>