I’m building 3d contingency tables from 3 variables in a data frame. Let’s suppose I’m constructing these via
table(x,y,z)
Where z is the variable on which I’m stratifying. I’d like to get rid of any (,,z(i)) where the number of observations in that stratum is 1.
How might I do this? I had trouble figuring out how to count observations in the first place, which I thought I’d be able to use, with subset, to pare down my contingency tables.
Supposing your data is contained in a data frame object named
data, this code should remove all data in strata with one observation.EDIT
This appears to work now. I’m not sure if this will work in general, but it works for this situation.