I have 5 columns each for a different variable and the values can either be “yes”, “no” or “unknown”. I want to create a flextable that shows the variable as the row and “yes”, “no”, and “unknown” as the columns with counts and percentages.
ID Temp Cough Runny nose Weight loss Chills
1 Yes No Yes No Yes
2 Yes Yes Unknown Yes Yes
3 Yes Unknown No No No
4 Yes Yes Yes Yes Yes
5 No No No No No
What I would like the output to look like is:
Yes No Unknown
n % n % n %
Temp 4 80 1 20 0 0
Cough 2 40 1 20 2 40
Runny Nose 2 40 2 40 1 20
Weight Loss 2 40 3 60 0 0
Chills 3 60 2 40 0 0
I know I need to use pivot and summarize to create the counts, but I am getting confused about how to map the variables and then how to create the double row headings and calculate percentages.