With mytable <- table(VarA, varB)
I've created a frequency table that looks like this:
1 2
0 0 5
1 5 7
2 0 0
3 7 9
4 0 0
5 5 10
Now I want to run some statistics with assocstats
and table2d_summary
on that table. But first I want to delete the empty values. That means the rows in the table with zero counts,
So how can I get rid of the rows with both frequencies of 0 (in my example it's row 2 and 4)?
For a data frame I could just use the subset
function:
mytable_noZ <- subset(mytbale, mytable$VarA != 0 & mytable$VarB != 0)
But it doesn't seem to be possible to refer to a variable (a column) by this method in a table.
A way that worked was deleting the rows "manually"
mytable_noZ <- mytable[-c(2,4),]
Which is easy in this example but I've some bigger tables.
I searched for a solution here and elsewhere but always only found ways to delete rows, variables and cases in data frames.
So hopefully someone can help me on this.