Relative Content

Tag Archive for rsum

sum for each category in factor variables

I would like to get a table that counts the frequencies of each factor category across all variables except id. I have a number of variables that each can contain 1, 0 or NA, and I want a table that gives me the frequency of each of those. Below I have changed NA to 2 because NA is not included as a category in factor variables and then I make each of the variables except id factors. I can’t figure out the final step to get the table in ‘want’ below that simply counts for each variable how many 1s, how many 0s and how many NAs.