title: idata.frame: Why error "is.data.frame(df) is not TRUE"?
body: <p>I'm working with a large data frame called exp (<a href="https://docs.google.com/leaf?id=0B1krGGny7BduNjMxYjAyNDUtYjAwNy00MTM0LWJlZjUtZTAyZGQyMzFiOTY5&amp;hl=en&amp;authkey=CMvtpuMP" rel="nofollow">file here</a>) in R.  In the interests of performance, it was suggested that I check out the idata.frame() function from plyr. But I think I'm using it wrong.</p>
  
  <p>My original call, slow but it works:</p>
  
  <pre><code>df.median&lt;-ddply(exp, 
                   .(groupname,starttime,fPhase,fCycle), 
                   numcolwise(median), 
                   na.rm=TRUE)
  </code></pre>
  
  <p>With idata.frame, <code>Error: is.data.frame(df) is not TRUE</code></p>
  
  <pre><code>library(plyr)
  df.median&lt;-ddply(idata.frame(exp), 
                   .(groupname,starttime,fPhase,fCycle), 
                   numcolwise(median), 
                   na.rm=TRUE)
  </code></pre>
  
  <p>So, I thought, perhaps it is my data.  So I tried the <code>baseball</code> dataset. The <code>idata.frame</code> example works fine: <code>dlply(idata.frame(baseball), "id", nrow)</code> But if I try something similar to my desired call using <code>baseball</code>, it doesn't work:</p>
  
  <pre><code>bb.median&lt;-ddply(idata.frame(baseball), 
                   .(id,year,team), 
                   numcolwise(median), 
                   na.rm=TRUE)
  &gt;Error: is.data.frame(df) is not TRUE
  </code></pre>
  
  <p>Perhaps my error is in how I'm specifying the groupings?  Anyone know how to make my example work?</p>
  
  <p>ETA:</p>
  
  <p>I also tried:</p>
  
  <pre><code>groupVars &lt;- c("groupname","starttime","fPhase","fCycle")
  voi&lt;-c('inadist','smldist','lardist')
  
  i&lt;-idata.frame(exp)
  ag.median &lt;- aggregate(i[,voi], i[,groupVars], median)
  Error in i[, voi] : object of type 'environment' is not subsettable
  </code></pre>
  
  <p>which uses a faster way of getting the medians, but gives a different error. I don't think I understand how to use idata.frame at all.</p>