title: Adding values to different list in r
body: <p>I have a data frame of fruit names <code>apple</code>, <code>orange</code>, and <code>banana</code>:</p>
  <pre><code>&gt; fruits
    X.apple. X.orange. X.apple..1 X.banana. X.apple..2  X.orange..1 X.banana..1 
      apple    orange    apple    banana      apple    orange      banana
  </code></pre>
  <p>I also have 3 lists: <code>apples = c()</code>, <code>oranges = c()</code>, and <code>bananas = c()</code>. They are simply simply lists.</p>
  <p>Now, I want to add in 0/1 value into the list according to the df.
  For example:
  apple list will become:
  <code>apple = (1,0,1,0,1,0,0)</code> in which 0 indicate there's no apple at that position of the df.</p>
  <p><code>oranges = (0,1,0,0,0,1,0)</code></p>
  <p><code>bananas = (0,0,0,1,0,0,1)</code></p>
  <p>Indeed my original data frame has thousands of elements and hundreds of lists. How can I do this fast?</p>
  <pre><code>&gt; dput(fruits)
  structure(list(X.apple. = structure(1L, .Label = &quot;apple&quot;, class = &quot;factor&quot;), 
      X.orange. = structure(1L, .Label = &quot;orange&quot;, class = &quot;factor&quot;), 
      X.apple..1 = structure(1L, .Label = &quot;apple&quot;, class = &quot;factor&quot;), 
      X.banana. = structure(1L, .Label = &quot;banana&quot;, class = &quot;factor&quot;), 
      X.apple..2 = structure(1L, .Label = &quot;apple&quot;, class = &quot;factor&quot;), 
      X.orange..1 = structure(1L, .Label = &quot;orange&quot;, class = &quot;factor&quot;), 
      X.banana..1 = structure(1L, .Label = &quot;banana&quot;, class = &quot;factor&quot;)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -1L))
  </code></pre>