Skip to content
Prev 26180 / 398502 Next

Excluding levels in table and xtabs

I'm trying to form contingincy tables among a set of character variables
which were read from a .csv file and 
have missing represented as "".  I want to exclude the missing levels
from the table.
[1] ""  "N" "Y"
[1] ""  "N" "Y"
Manix
CPIC        N    Y
     272    4   15
   N 154 2812 1472
   Y 158  466 4870
Manix
CPIC        N    Y
     272    4   15
   N 154 2812 1472
   Y 158  466 4870

The only way I can exclude them is by

t <- table(CPIC, Manix)
t <- t[-1,-1]

that's not to hard in this case, but my application is to a much
larger table where this gets unweildly.