title: Error: object '...' not found
body: <p>I'm trying to write a function using ddply package. I've read several solutions, but I couldn't figure it out how to tackle this issue in my case.</p>
  
  <pre><code>Rolling &lt;- function(ID, RP){ 
   require(plyr)
   cn=colnames(ID)
   Rolling3M=ddply(ID, cn[2:(length(cn)-1)], transform, Rolling3M = as.numeric(filter(v3,c(1,rep(1,times=RP)),sides=1)))
   return(Rolling3M)
  }
  
   v1=c("a","a","a","a","a","a","a","b","b","b","b","b","b")
   v2=c("c","c","c","d","d","d","d","c","c","c","d","d","d")
   v3=c(1:13)
   df = data.frame(v1,v2,v3)
   output=Rolling(df, 3)
  </code></pre>
  
  <p>I got this error message: <code>Error: object 'RP' not found</code></p>
  
  <p>I'd like to do the same as this would do:</p>
  
  <pre><code>output=ddply(df, .(v1,v2),transform, Rolling3M=as.numeric(filter(v3,c(1,rep(1,2)), sides=1)))
  </code></pre>