title: How can I calculate an empirical CDF in R?
body: <p>I'm reading a sparse table from a file which looks like:</p>
  
  <pre><code>1 0 7 0 0 1 0 0 0 5 0 0 0 0 2 0 0 0 0 1 0 0 0 1
  1 0 0 1 0 0 0 3 0 0 0 0 1 0 0 0 1
  0 0 0 1 0 0 0 2 0 0 0 0 1 0 0 0 1 0 1 0 0 1
  1 0 0 1  0 3 0 0 0 0 1 0 0 0 1
  0 0 0 1 0 0 0 2 0 0 0 0 1 0 0 0 1 0 1 0 0 1 1 2 1 0 1 0 1
  </code></pre>
  
  <p>Note row lengths are different.</p>
  
  <p>Each row represents a single simulation. The value in the i-th column in each row says how many times value i-1 was observed in this simulation. For example, in the first simulation (first row), we got a single result with value '0' (first column), 7 results with value '2' (third column) etc.</p>
  
  <p>I wish to create an average cumulative distribution function (CDF) for all the simulation results, so I could later use it to calculate an empirical p-value for true results.</p>
  
  <p>To do this I can first sum up each column, but I need to take zeros for the undef columns.</p>
  
  <p>How do I read such a table with different row lengths? How do I sum up columns replacing 'undef' values with 0'? And finally, how do I create the CDF? (I can do this manually but I guess there is some package which can do that).</p>