very new to R and am struggling to understand how to plot multiple categorical variables. From a survey there was a question that was formatted in a checkbox grid, therefore respondents were able to check multiple options for multiple items. It looks something like this:
The question is getting at what apps do you use and how do you use them? I have the code for all of it down here. Realistically there are 12 apps people to choose from but I'm just showing 4 for these purposes.
data1 <- data.frame(apps = c("Education", "Leisure", "Research","Shopping",
"Business", "Organization", "Reporting"),
yes = c("5", "6","2","1","2","1","1"),
no = c("6", "5","9","10","9","10","10"))
data2 <- data.frame(apps = c("Education", "Leisure", "Research","Shopping",
"Business", "Organization", "Reporting"),
yes = c("6", "6","3","1","2","1","1"),
no = c("5", "5", "8", "10", "9","10","10"))
data3 <- data.frame(apps = c("Education", "Leisure", "Research","Shopping",
"Business", "Organization", "Reporting"),
yes = c("6", "6","3","1","2","1","1"),
no = c("5", "5", "8", "10", "9","10","10"))
data4 <- data.frame(apps = c("Education", "Leisure", "Research","Shopping",
"Business", "Organization", "Reporting"),
yes = c("4", "4","2","2","3","1","1"),
no = c("7", "7", "9", "9", "8","10","10"))
This is the chart I've come up with for ONE of them using the code below.
data1 %>%
mutate(
yes = as.numeric(yes),
no = as.numeric(no)
) %>%
gather(key = "success", value=value, -apps) %>%
ggplot(aes(x=apps, y=value, fill=success)) +
geom_bar(position = "stack", stat = "identity") +
labs(title = "Appliations for App Use", x= "Applications", y= "# of individuals", fill = "Legend")+
scale_fill_manual(values=c("purple", "pink"))
So I have a few questions:
- Is there a way to make a "single" chart that shows up all at the same time for each app? I've inserted a picture for what I mean Example chart of what I'd like. Or will I have to write the code for all 12 and run it?
- Is there a better way to visualize this? I've thought about a mosaic plot but I'm not even sure if I should even be considering it or if I should just stick with normal bar graphs.
Any help would be much appreciated on this, as I still navigate how to code in R.