title: Get all rows where one row for a particular value matches regex
body: <p>I wasn't really sure how to phrase the title but here goes.</p>
  
  <p>I have a dataset as follows</p>
  
  <pre><code>HNum       Grade
  1234       LGD
  1234       NDBE
  1234       NDBE
  5678       NDBE
  5678       HGD
  9765       LGD
  7556       LGD
  7556       NDBE
  </code></pre>
  
  <p>If a row has LGD in it I want to get all the rows for the HNum that is associated with so the output would be:</p>
  
  <pre><code>HNum       Grade
  1234       LGD
  1234       NDBE
  1234       NDBE
  9765       LGD
  7556       LGD
  7556       NDBE
  </code></pre>
  
  <p>I really don't know how to do this as I guess it would rely of matching a row in Grade, getting the HNum and then re-grepping the original dataset to get the rows with that <code>HNum</code>.</p>
  
  <p>I can do the grep something like:</p>
  
  <pre><code>LGDSubset &lt;- unique(df[grep("LGD", df$Grade,perl=TRUE), ])
  HNumLGD&lt;-as.vector(LGDSubset$HNum)
  </code></pre>
  
  <p>which should give me a vector of unique <code>HNum</code>'s</p>
  
  <p>but what I don't know how to do is then iterate across this vector and pull out all the rows from the original dataframe based on each <code>HNum</code></p>