Reputation: 633
I've got a data frame containing, say, the columns v1, v2, ..., v30
which contain the same factor variables, although the levels are different from column to column ('210N' under v3 might not appear under v5, for example - I'm not sure whether that is contributing to my trouble). Ideally, I'm hoping that, rather than doing a table(df$v1)
, table(df$v2)
, ... and onward to table(df$v30)
, and adding up all the counts of the value I'm interested in, there's some kind of solution out there that performs the equivalent of table(df$[, v1...v30])
- without requiring me to enforce the same levels across all columns, as in theory there should be around ~6000 levels in all.
So far, I've naively tried to merge a table on v1 with a table on v2, with all=TRUE
set, although that doesn't do the trick: the the ensuing table contains two different counts for the same factor level, i.e, '210N' appears twice, but with different frequencies.
Upvotes: 1
Views: 1615