title: How to Fill in Empty Matrix in R with Loop
body: <p>I have a blank matrix called Trial that is 5000 X 5000, but i'll put a small snippet.</p>
  
  <pre><code>     a  b  c  d  e  f 
   a  
  
   b  
  
   c  
  
   d  
  
   e  
  
   f  
  </code></pre>
  
  <p>and I want to fill the Matrix, with a Data Table I have.</p>
  
  <pre><code>Name Value
  -----------
  Cat   A 
  Cat   B
  Cat   E
  Dog   D
  Dog   C
  Dog   F
  </code></pre>
  
  <p>So basically in the end, I want the matrix to be filled like this:</p>
  
  <pre><code>     a  b  c  d  e  f 
   a   1  1  0  0  1  0
  
   b   1  1  0  0  1  0
  
   c   0  0  1  1  0  1
  
   d   0  0  1  1  0  1
  
   e   1  1  0  0  1  0
  
   f   0  0  1  1  0  1
  </code></pre>
  
  <p>So all the values relating to the Name will be 1, and if they don't relate they will be 0. For example, A and F don't relate because they are different names (cat and dog), thus they will get a 0.</p>