How to convert data from monthly to annual in R? : <p>I need to convert monthly observations into annual -- year-country instead of month-country. </p>

<p>This is how the data looks: </p>

<pre><code>year    month   countrycode troop
1990    1            USA    6
1990    2            USA    4
1990    3            CANADA 3
1990    4            CANADA 6
1991    1            USA    5
1991    2            USA    6
1991    3            CANADA 3
1991    4            CANADA 6
</code></pre>

<p>I would like to convert this into: </p>

<pre><code>year    countrycode troop
1990         USA    10
1990         CANADA 9
1991         USA    11
1991         CANADA 9
</code></pre>

<p>I have no clue how to start so I'm grateful for all suggestions! </p>
