title: R list within a dataframe calculation
body: <p>I have the following dataframe df:</p>
  <pre><code>     tile_type_index
  71                17
  81                 8
  71.1              17
  81.1               8
  71.2              17
  71.3              17
                                                 material_balance
  71   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  81   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  71.1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  81.1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  71.2 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  71.3 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
       material_spend
  71        0.3333333
  81        0.3333333
  71.1      0.3333333
  81.1      0.3333333
  71.2      0.3333333
  71.3      0.3333333
  
  df&lt;-structure(list(tile_type_index = c(17L, 8L, 17L, 8L, 17L, 17L
  ), material_balance = list(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0)), material_spend = c(0.333333333333333, 
  0.333333333333333, 0.333333333333333, 0.333333333333333, 0.333333333333333, 
  0.333333333333333)), row.names = c(&quot;71&quot;, &quot;81&quot;, &quot;71.1&quot;, &quot;81.1&quot;, 
  &quot;71.2&quot;, &quot;71.3&quot;), class = &quot;data.frame&quot;
  </code></pre>
  <p>For each row of df, I want to add material_spend to the element of material_balance that has the index given tile_type_index. So I want to do something like material_balance[tile_type_index]&lt;-material_spend but I'm not sure how to do this.</p>
  <p>The result should look like the following:</p>
  <pre><code>     tile_type_index
  71                17
  81                 8
  71.1              17
  81.1               8
  71.2              17
  71.3              17
                                                 material_balance
  71   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.33, 0, 0, 0
  81   0, 0, 0, 0, 0, 0, 0, 0.33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  71.1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.33, 0, 0, 0
  81.1 0, 0, 0, 0, 0, 0, 0, 0.33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  71.2 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.33, 0, 0, 0
  71.3 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.33, 0, 0, 0
       material_spend
  71        0.3333333
  81        0.3333333
  71.1      0.3333333
  81.1      0.3333333
  71.2      0.3333333
  71.3      0.3333333
  </code></pre>