title: R dplyr - error in subsetting of local data frame
body: <p>As part of a larger and more complex body of code, I am running into a dplyr / local data frame challenge. As the simplified example per below shows, the code includes a basic type of subsetting that works in base R:   </p>
  
  <pre><code>#creation of data frame
  dat=data.frame(group=c(rep(c("a","b","c","d"),2)),value=(seq(1,8,1)))
  othergroup=dat[dat[,"group"]==dat[2,"group"],]
  othergroup 
  </code></pre>
  
  <p>This gives the desired answer:</p>
  
  <pre><code> group value
  2     b     2
  6     b     6
  
  #loading dplyr
  require(dplyr)               
  othergroup=dat[dat[,"group"]==dat[2,"group"],]
  othergroup #still works
  </code></pre>
  
  <p>After just loading dplyr, all still works. However, after I run a dplyr operation, then a local data frame is created that no longer allows similar subsetting.</p>
  
  <pre><code>#pro-forma dplyr operation
  dat = dat %&gt;%
    group_by(group)
  
  othergroup=dat[dat[,"group"]==dat[2,"group"],] #error message
  
  Error in Ops.data.frame(dat[, "group"], dat[2, "group"]) : 
  ‘==’ only defined for equally-sized data frames
  </code></pre>
  
  <p>I understand that one can use the select function in dplyr, but I would like to re-use some existing code. Is there a way to coerce a dplyr generated "local data frame" back into a regular data frame?</p>