How to update a summary data.frame field with a value from a different data.frame in R?
<p>I'm creating a summary data.frame with counts, N and a percentage.
The summary data.frame has names -> category, n, count and percentage.
The counts data.frame has names -> category, count.
category is character. Often the rows in the counts data frame will be less than the rows in the summay.</p>

<p>The way I'd do this in MSSQL is</p>

<pre><code>update summary
set summary.count = counts.count
from summary
inner join counts
on summary.category = counts.category
</code></pre>

<p>How could this be done in R?</p>

<p>Supporting code.</p>

<pre><code>summary &lt;- data.frame(category=c("apples","oranges","pears"),N=10,count=0,percentage=0)
&gt; summary
  category  N count percentage
1   apples 10     0          0
2  oranges 10     0          0
3    pears 10     0          0
&gt; counts &lt;- data.frame( category=c("apples","pears"), count = c(5,5) )
&gt; counts
  category count
1   apples     5
2    pears     5

# desired outcome after processing
&gt; summary
  category  N count percentage
1   apples 10     5          0.5
2  oranges 10     0          0
3    pears 10     5          0.5
</code></pre>