R subset rows for all occurrences of first variable in column
<p>I would like to create a subset of a large data frame based on two columns, ColA and ColB (below). For each variable in ColA (e.g. A, B, C...), I would like to extract the rows corresponding to each occurrence of the first variable in ColB. Therefore DF1:</p>

<pre><code>ColA  ColB  ColC
A     Red     7thing
A     Red     OneBot
A     Blue    BotOne
B     Green   Thing7
B     Green   Twosies
B     Green   Square
B     Yellow  Circle
B     Yellow  Polygon
B     Purple  Triangle
B     White   Octagon
C     Orange  Cube
C     Black   Line
</code></pre>

<p>Would become DF2:</p>

<pre><code>ColA  ColB  ColC
A     Red     7thing
A     Red     OneBot
B     Green   Thing7
B     Green   Twosies
B     Green   Square
C     Orange  Cube
</code></pre>

<p>I am not concerned about duplicates in ColC, and there is no pattern to the number of occurrences of a variable in ColB. The related subsetting strategies I have found focus on extracting unique cases, but I have neither come across nor been able to devise an approach to permit selecting all occurrences of the first variable type and would be grateful for some assistance.</p>

<p>I have tried </p>

<pre><code>DF2 &lt;- DF1[match(unique(DF1$ColB), DF1$ColB),]
</code></pre>

<p>...and subsetting that targets the variable when the variable content is known (e.g. <a href="https://stackoverflow.com/questions/34795350/subset-first-n-occurrences-of-certain-value-in-dataframe-in-r">Subset first n occurrences of certain value in dataframe in R</a>), these are not appropriate seemingly.</p>