Skip to content
Prev 274798 / 398506 Next

Detect and replace omitted data

On Oct 18, 2011, at 2:24 PM, Sarah Goslee wrote:

            
I could not figure out what you wanted precisely. If "day" is the row  
designator, and you want values by 'unit' and 'day' with zeros for the  
missing, then that is exactly what `xtab` delivers:

 > xtabs(value ~ day+unit, data=x)
    unit
day  1  2  3  4  5  6  7  8 10 12 14 16
   4 25 34  3 25 38 18 19 33  0  0  0  0
   6  0 22  0 42  0 37  0  4 12 31 17 28

You cannot get much more concise than that.