title: Generate 'ecdf' on a grouped data frame
body: <p>How to store an ecdf output from a grouped data frame</p>
  
  <p>Hi all,</p>
  
  <p>My data looks like this:</p>
  
  <pre><code>age lab  value  
  20  wbc  7.0   
  20  wbc  6.5
  20  rbc  3.5
  30  rbc  4.0
  30  plt  100
  30  plt  120
  40  wbc  5.0
  40  wbc  7.5
  40  rbc  4.1
  ... ...  ...
  </code></pre>
  
  <p>I would like to generate and store ecdf's for the variable "value" for all the possible "age"-"lab" combinations. The output should be a list of "ecdf" objects. I plan to use these ecdf's at a later point in my analysis and apply it to another dataset.</p>
  
  <p>What I tried so far:  </p>
  
  <pre><code>data %&gt;% group_by(age,lab) %&gt;% do(ecdf(.$value))
  </code></pre>
  
  <p>No success so far. I am getting:</p>
  
  <pre><code>Error: Results 1, 2, 3, 4, 5, ... must be data frames, not ecdf/stepfun/function
  </code></pre>
  
  <p>Any thoughts?</p>
  
  SOLVED
  
  <p>If this helps anyone, I split the original data-frame by two factors, then used an lapply on the third column.</p>
  
  <pre><code>spl &lt;- split(data, list(data$age, data$lab))
  ecdfs &lt;- lapply(spl, function(x) ecdf(x$value)
  </code></pre>