title: How can I count the number of instances a value occurs within a subgroup in R?
body: <p>I have a data frame that I'm working with in R, and am trying to check how many times a value occurs within its larger, associated group. Specifically, I'm trying to count the number of cities that are listed for each particular country. </p>
  
  <p>My data look something like this:</p>
  
  <pre><code>City              Country
  =========================
  New York           US
  San Francisco      US
  Los Angeles        US
  Paris             France
  Nantes            France
  Berlin            Germany
  </code></pre>
  
  <p>It seems that table() is the way to go, but I can't quite figure it out — how can I find out how many cities are listed for each country? That is to say, how can I find out how many fields in one column are associated with a particular value in another column?</p>
  
  <p>EDIT:</p>
  
  <p>I'm hoping for something along the lines of </p>
  
  <pre><code>3    US
  2    France
  1    Germany
  </code></pre>