title: How to assign values to a column for a subset of data frame rows
body: <p>I have a large data frame and I am trying to assign values to a particular data column for specific subsets.</p>
  
  <pre><code>subset(P2Y12R_binding_summary,(SYSTEM=="4NTJ")&amp;(VARIANT=="D294N"))
    SYSTEM VARIANT  MODEL EPSIN INP dE_water_free dE_ERR_water_free dE_water_periodic dE_ERR_water_periodic
  1   4NTJ   D294N LVLSET     1   1       -42.155          29.28460           -42.205              29.52604
  2   4NTJ   D294N LVLSET     1   2       -34.225          29.75176           -34.235              29.96571
  3   4NTJ   D294N LVLSET    20   1       -65.163          40.62241           -65.163              40.52564
  4   4NTJ   D294N LVLSET    20   2       -57.454          41.04459           -57.454              41.26962
  5   4NTJ   D294N    SES     1   1       -23.406          30.56636           -23.335              30.75794
  6   4NTJ   D294N    SES     1   2       -15.434          30.70035           -15.414              30.85944
  7   4NTJ   D294N    SES    20   1       -64.351          40.65919           -64.350              40.51345
  8   4NTJ   D294N    SES    20   2       -56.342          41.23456           -56.542              41.21865
  </code></pre>
  
  <p>Now suppose I add a new column to the frame ( Ki_expt ) using</p>
  
  <pre><code>P2Y12R_binding_summary$Ki_expt &lt;- 0
  </code></pre>
  
  <p>And I want to update values for this column for only the rows corresponding to the subset above.</p>
  
  <p>Trying the naive approach fails:</p>
  
  <pre><code>&gt;subset(P2Y12R_binding_summary,(SYSTEM=="4NTJ")&amp;(VARIANT=="D294N"))$Ki_expt = 42.2
  </code></pre>
  
  <p>or </p>
  
  <pre><code>&gt;subset(P2Y12R_binding_summary,(SYSTEM=="4NTJ")&amp;(VARIANT=="D294N"))$Ki_expt &lt;- 42.2
  </code></pre>
  
  <p>Both yield the error message: </p>
  
  <pre><code>Error in subset(P2Y12R_binding_summary, (SYSTEM == "4NTJ") &amp; (VARIANT ==  : 
  could not find function "subset&lt;-"
  </code></pre>
  
  <p>Does anyone know of the appropriate way to do this? Obviously, it would be possible with a for loop, but that seems rather klunky and would probably be quite slow (as previous experience seems to show).</p>