说实话,还是没太明白你想要的,结合上次你的数据,我是这样操作的,不知是否如你所想:
#这是上次数据gather后的数据,是否是你dput的样子?
structure(list(Area_of_Speciality = c("Internal Medicine", "Emergency Medicine",
"Internal Medicine", "Childrens Clinic", "Endocrinology", "Family Medicine",
"Internal Medicine", "Family Medicine", "Childrens Clinic", "Emergency Medicine",
"Emergency Medicine", "Internal Medicine", "Emergency Medicine",
"Internal Medicine", "Childrens Clinic", "Endocrinology", "Family Medicine",
"Internal Medicine", "Family Medicine", "Childrens Clinic", "Emergency Medicine",
"Emergency Medicine", "Internal Medicine", "Emergency Medicine",
"Internal Medicine", "Childrens Clinic", "Endocrinology", "Family Medicine",
"Internal Medicine", "Family Medicine", "Childrens Clinic", "Emergency Medicine",
"Emergency Medicine", "Internal Medicine", "Emergency Medicine",
"Internal Medicine", "Childrens Clinic", "Endocrinology", "Family Medicine",
"Internal Medicine", "Family Medicine", "Childrens Clinic", "Emergency Medicine",
"Emergency Medicine", "Internal Medicine", "Emergency Medicine",
"Internal Medicine", "Childrens Clinic", "Endocrinology", "Family Medicine",
"Internal Medicine", "Family Medicine", "Childrens Clinic", "Emergency Medicine",
"Emergency Medicine", "Internal Medicine", "Emergency Medicine",
"Internal Medicine", "Childrens Clinic", "Endocrinology", "Family Medicine",
"Internal Medicine", "Family Medicine", "Childrens Clinic", "Emergency Medicine",
"Emergency Medicine", "Internal Medicine", "Emergency Medicine",
"Internal Medicine", "Childrens Clinic", "Endocrinology", "Family Medicine",
"Internal Medicine", "Family Medicine", "Childrens Clinic", "Emergency Medicine",
"Emergency Medicine"), Meds = c("Asprin", "Asprin", "Asprin",
"Asprin", "Asprin", "Asprin", "Asprin", "Asprin", "Asprin", "Asprin",
"Asprin", "Vitamin D", "Vitamin D", "Vitamin D", "Vitamin D",
"Vitamin D", "Vitamin D", "Vitamin D", "Vitamin D", "Vitamin D",
"Vitamin D", "Vitamin D", "Tylenol", "Tylenol", "Tylenol", "Tylenol",
"Tylenol", "Tylenol", "Tylenol", "Tylenol", "Tylenol", "Tylenol",
"Tylenol", "Advil", "Advil", "Advil", "Advil", "Advil", "Advil",
"Advil", "Advil", "Advil", "Advil", "Advil", "Cough Syrup", "Cough Syrup",
"Cough Syrup", "Cough Syrup", "Cough Syrup", "Cough Syrup", "Cough Syrup",
"Cough Syrup", "Cough Syrup", "Cough Syrup", "Cough Syrup", "Vitamin c",
"Vitamin c", "Vitamin c", "Vitamin c", "Vitamin c", "Vitamin c",
"Vitamin c", "Vitamin c", "Vitamin c", "Vitamin c", "Vitamin c",
"Vitamin k", "Vitamin k", "Vitamin k", "Vitamin k", "Vitamin k",
"Vitamin k", "Vitamin k", "Vitamin k", "Vitamin k", "Vitamin k",
"Vitamin k"), Response = c("Yes", "Yes", "Yes", "Yes", "No",
"Yes", "Yes", "Yes", "No", "Yes", "Yes", "Yes", "No", "No", "Yes",
"Yes", "Yes", "Yes", "Yes", "No", "Yes", "No", "Yes", "No", "No",
"Yes", "Yes", "No", "Yes", "No", "No", "No", "Yes", "No", "No",
"No", "Yes", "No", "No", "No", "Yes", "No", "Yes", "Yes", "Yes",
"No", "Yes", "Yes", "No", "Yes", "No", "No", "No", "Yes", "Yes",
"No", "No", "Yes", "Yes", "No", "No", "Yes", "Yes", "No", "Yes",
"Yes", "Yes", "No", "Yes", "Yes", "No", "Yes", "Yes", "Yes",
"No", "Yes", "Yes")), row.names = c(NA, -77L), class = "data.frame")
##以下是绘图:我这里采用的是百分比柱状图,它可以展示给你每类的占比,我把No这类颜色设定为白色,以便于忽略,
ggplot(plor_bar) +
geom_bar(aes(x = Meds, fill = Response),position = 'fill') +
facet_wrap(~ Area_of_Speciality) +
scale_fill_manual(values=c(Yes = "blue", No = "white"))
如下为结果截图: