title: dlply function not being applied to subset
body: <p><strong>Data:</strong></p>
  
  <pre><code>test_dat&lt;-data.frame("ID"=c(rep("a",times=19),rep("b",times=20)),
                        "time"=seq(1,39,1),
                        "AMT"=c(0.5,  0.5,    0.5,    0.5,    0.5,    0.5,    0.5,    0.5,    0.5,    0.005,  
                                0.005,    0.005,  0.003,  0.0088, 0.0074, 0.006,  0.0023, 0.0028, 
                                0.0034,0.5,   0.5,    0.5,    0.5,    0.5,    0.5,    0.5,    0.5,    
                                0.5,  0.005,  0.005,  0.005,  0.0037, 0.0088, 0.0079, 0.005,  
                                0.006,    0.0034, 0.0042, 0.0029),
                        "ND_format"=c(TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   
                                      TRUE,   TRUE,   TRUE,   FALSE,  FALSE,  FALSE,  FALSE,  FALSE,  
                                      FALSE,  FALSE,  TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   
                                      TRUE,   TRUE,   TRUE,   TRUE,   TRUE,   FALSE,  FALSE,  FALSE,  TRUE,   
                                      FALSE,  FALSE,  FALSE,  FALSE))
  </code></pre>
  
  <p>Problem: 
  I am trying to use the <code>NADA</code> package to compute maximum likelihood regression on a censored data object. I have a larger data set where I would like to apply a function across subsets of one dataframe. See below:</p>
  
  <pre><code>library(NADA)
  library(plyr)
  cen_objects&lt;-dlply(test_dat, .(ID), function(x,y,z) cenreg(Cen(test_dat$AMT,test_dat$ND_format)~as.numeric(test_dat$time)))
  summary(cen_objects)
  str(cen_objects[[1]])
  cen_objects[[1]]@survreg$coefficients
  
  interceptz&lt;-ldply(names(cen_objects),function(x) cen_objects[[x]]@survreg$coefficients)
  interceptz$ID&lt;-names(cen_objects)
  interceptz  
  </code></pre>
  
  <p>The problem is that this currently does not apply the function to each unique "ID" (i.e. the intercepts should be different for "a" and "b"). And when I try this:</p>
  
  <pre><code>cen_objects&lt;-dlply(test_dat, .(ID), function(x,y,z) cenreg(Cen(AMT,ND_format)~as.numeric(time)))
  </code></pre>
  
  <p>I get an</p>
  
  <blockquote>
    <p>"Error in Cen(AMT, ND_format) : object 'AMT' not found"</p>
  </blockquote>
  
  <p>Thanks for the help, I am new to split-apply-combine and I am afraid I do not pass functions correctly. Detailed answers will help me write these functions better in the future.</p>