I'm battling with something that I think should be so simple!
I have researched frequency tables in R and can't figure out what to do.
I have a data set with different questionnaires within this data set.
I.e., The first questionnaire is made up of 10 items, and I have a separate column for each item/variable, i.e. Question 1, Question 2, Question 3 etc will each have it's own column.
Within each column, there are 400 responses (i.e., participants) where each participant gives a response of 0,1, or 2.
All I want to do, is generate a frequency count on all variables (i.e., Question 1, Question 2, Question 3 etc) so that I get a summary for all variables - for example:
0 = 100
1 = 200
2 = 97
NA = 3
Total = 400
How do I generate this in a simple, neat table?
df #the name of your raw table
table(df$columnName) #This command should create the table for you
if you also want to see a total on the end, you can do this:
exampleTable <- table(df$columnName)
exampleTable <- cbind(exampleTable, Total = rowSums(exampleTable))