I'm new to R.
This is my dataset
df <- tribble( ~Area_of_interst ,~Meds,~Response,
"Internal Med", "asprin", "yes",
"Internal Med", "vitamins","no",
"Internal Med", "folic acid","yes",
"Emergency Med", "asprin", "yes",
"Emergency Med", "vitamins","no",
"Emergency Med", "folic acid","yes",
I have about 6 different "Area_of_interest". As you can all my variables are categorical. I want to plot a barplot for all the 6 different "Area_of_interest" by meds whiles only filtering those with response "yes" on the same barplot. The barplot should have their respective confidence interval.
I have two questions:
After I used the summarise function, I didn't access to the variable "Area of interest". All the variables are categorical. How do I compute the proportions without using summarise function or I do fix my code below for me to retain all my columns
Compute my confidence interval for barplot for each "area of interest".
df %>% na.omit() %>%
group_by(meds, Response) %>% summarise( ct=n()) %>%
mutate(propn =paste0( round(100*ct/sum(ct),1),"%" )) %>%
filter(Response=="yes") %>% ggplot(aes(x=meds, y=propn)) +
geom_col(position = "dodge")