Skip to content
Prev 247565 / 398503 Next

matrix manipulations

Monica -
    Perhaps this small example can demonstrate how factors can
solve your problem:
cat1 cat2 cat3 cat4 cat5 cat6
   land    14   17   18   22   19   23
   water   19   15   16   11   10   16

This works because when you include all possible levels in a factor, R will 
automatically put zeroes in the right places when you use table():
cat1 cat2 cat3 cat4 cat5 cat6
   land     0   17    0    0   19   23
   water    0   15    0    0   10   16
cat1 cat2 cat3 cat4 cat5 cat6
   land    14    0   18   22    0    0
   water   19    0   16   11    0    0

Hope this helps.
 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Mon, 17 Jan 2011, Monica Pisica wrote: