I want to have multiple pie charts per column and across two groups.
My data looks like this:
mydf <- data.frame(ID, age, gender, diagnosis, A1, A2, A3)
mydf
ID age gender diagnosis A1 A2 A3
a 22 female 1 A D B
b 34 male 2 B E NA
c 55 female 2 C B A
d 55 female 1 NA A B
e 45 male 1 E D B
here A1, A2, and A3 refer to the questions in the test I applied to participants and the letters below represent the answer chosen by the participant. So, it is a categorical value. Diagnosis 1 and 2 refer to whether the participant is diagnosed or not with the illness.
I want to calculate the percentage-wise frequencies for each question(omitting NA values) and make a pie chart by diagnosis. Is there any code you can think of that would provide me with multiple pie charts at one go or should I write a separate code for each question(I have so many questions, that's why I am asking? :D)
So, in the end, I would like to have pie charts like this next to each other for each question:
Thank you so much!