I am brand new to R and a teacher, so thank you for your patience. I've searched many other questions on Likert stacked bar charts (this one is close, but not exactly what I am struggling with). I can't seem to find one that discusses how to pull the results of both survey pre- and post-test into the same stacked bar chart. I've read through Hayley's R for Data Science book, examples on GitHub, the R Companion Handbook, and the R Cookbook. Still really need some help, as a beginner.
I have a set of 12 student questions, each with a pre- and post-test response, on a scale of Strongly Agree to Strongly Disagree.
My question is: How did the student survey responses change before and after a test?
My data originally was displayed as:
Student sex(F=0,M=1) PreTestQ1 PostTestQ1
1 0 Agree Disagree
2 0 Disagree Agree
3 1 Agree Agree
4 1 Disagree Agree
First, I converted the Agrees/Disagrees to numerical data (Strongly Agree = 1, Strongly Disagree = 4, no Neutral option) and tidied the data from wide to long using:
# Set data frame as wide
msse_wide <- read_xls("ProcessDataMSSE.xls")
colnames(msse_wide) # Displays names of columns
head(msse_wide)
# Set data frame as long, after running wide code above
msse_long <- msse_wide %>%
gather(question,obs_prepost, c(2:25)) # This pulls the columns from 2 to 25 (not including the "sex" column), test it out first as a precaution
# NOW MY DATA IS TIDY!!!! :)
And I got:
> msse_long
# A tibble: 1,824 x 3
sex question obs_prepost
<dbl> <chr> <dbl>
1 0 1Pre 3
2 0 1Pre 3
3 0 1Pre 2
4 0 1Pre 3
5 0 1Pre 2
6 0 1Pre 3
7 0 1Pre 3
8 0 1Pre 2
9 0 1Pre 2
10 0 1Pre 4
# … with 1,814 more rows
Now I would like to visualize the percentages of Strongly Agree --- Strongly Disagree responses as a stacked bar chart, using percentage responses, AND comparing pre- and post-test as stacked bars one on top of the other (so, with 12 questions pre- and post-, I will have 24 total stacked bar charts).
The ultimate goal is similar to this example from R Companion: Simple Stacked Bar Chart ...except I am stuck on how to pull percentages out of my data, and compare pre- and post-tests one on top of the other.