title: subset dataframe using grep
body: <p>I have dataframe named SCC in which one of the columns is EI.Sector. I would like to subset the data frame based on the condition:</p>
  
  <pre><code>grepl(".*Coal.*", SCC$EI.Sector)
  </code></pre>
  
  <p>So, I pass the command:</p>
  
  <pre><code>subset(subset=grepl(".*Coal.*", SCC$EI.Sector), SCC)
  </code></pre>
  
  <p>but I get an error saying ---Error in SCC$EI.Sector : $ operator is invalid for atomic vectors. It works on a dataframe that was posted in this forum:</p>
  
  <pre><code>x &lt;- c("G448", "G459", "G479", "G406")
  y &lt;- c(1:4)
  My.Data &lt;- data.frame (x,y)
  &gt; subset(subset=grepl("G45.*", My.Data$x), My.Data)
     x y
  2 G459 2
  </code></pre>
  
  <p>Can someone tell me why this is happening? Thanks in advance.</p>