I have a dataframe that contains a number columns which are all coded as factor variables. Each column is based on Questions with only two choices: 1=yes and 2=no, or missing. Each row would be a participant.
Here a simplified version:
Q_1 Q_2 Q_3
1 1 1
2 1 1
1 2 NA
2 1 2
Ideally, I would like to create an overview dataframe with each question as row and the counts of how often a variable each factor occurred. That would also allow me to use dplyrs mutate function ands calculate the percentages etc.
I would like a frame with the count data:
Yes No NA
Q_1 2 2 0
Q_2 3 1 0
Q_3 2 1 1
I initially though of simply using group_by and the count function, however there is no real grouping variable, because the factor levels (which happen to be the same for all columns) would be my grouping variable.