Filter by year and column number in R
<p>I am relatively new to R and I am trying to filter a data frame by year and specific column numbers. Here's a toy example of my data set: </p>

<pre><code>Year    UniqueID       Bench.St   SiteEUI
2011      1              Yes        450
2011      2               No        300
2011      3               No         NA
2011      4               NA        350
2012      1               No        400
2012      2              Yes        200
2013      1              Yes        500
2013      2               No        100
2013      3              Yes        475
</code></pre>

<p>I am trying to extract the rows which have repeated information from 2011 to 2013 sorted through the UniqueIDs. Using the example above, 2011 has 4 UniqueIDs (1,2,3,4), 2012 has 2 UniqueIDs(1,2) and 2013 has 3 UniqueIDs(1,2,3). Since UniqueIDs 1 and 2 are present in the three years, I would like to extract the UniqueID rows for those years. Therefore the dataset above reduces to: </p>

<pre><code>Year    UniqueID        Bench.St        SiteEUI
2011      1               Yes              450
2011      2                No              300
2012      1                No              400
2012      2               Yes              200
2013      1               Yes              500
2013      2                No              100    
</code></pre>

<p>I believe that dplyr or some other simple function may be able to do this but I am not sure how to go about it. Thanks!</p>