I have a dataframe that includes a number of variables from a survey in which each variable is a statement that respondents could either agree with (Y) or disagree with (N). I would ideally like to create a bar chart that includes all of these variables on the x axis, with the y axis as the count of people who agreed. Which is the other twist - I don't want to chart those who disagreed; only those who agreed. I think I can figure this part out - I'm assuming changing the Ns to NAs - but any guidance is appreciated.
But from what I've read of ggplot2, it's not made to handle more than one variable on the x axis, and the only solution I've seen for others is to do a long pivot, but those situations don't seem to fit what I'm trying to do.
So with the below example, the bar chart would ideally include three bars on the x axis, with the first bar representing all the Ys for Statement1, the second representing all the Ys for Statement2, and the third bar would be all the Ys for Statement 3.
library(dplyr)
library(tidyr)
library(ggplot2)
df <- data.frame(
Statement1 = c("Y", "Y", "N", "N", "Y"),
Statement2 = c("Y", "N", "Y", "N", "N" ),
Statement3 = c("N", "Y", "N", "Y", "Y")
)
df