Simple Data Visualization and Data File

Simple bar plots of Q22 and Q23 by requested variables (with the exception of a couple: 1 I couldn't see the options, and the other is a type-in response so I'm figuring how to sort it).

Q24, 25, and 26 will likely need a different type of plot as they are all categorical variables -- Stacked bar chart perhaps

The colors are gray and boring at the moment, but can/will be changed later to suit what you prefer.
This commit is contained in:
rehughes07 2021-11-29 16:18:07 +00:00
parent 6a8fc8f590
commit 8b0670f432
2 changed files with 269 additions and 88 deletions

View file

@ -142,20 +142,201 @@ table(Q3_1factor)
- Q18 (respondent gender)
- Q19 (respondent ethnic self-desc)
```{r Plots}
```{r Plots Q22}
library(ggplot2)
summaries_data <- read.csv("./data/visualization data.csv")
# Q22
testplot <-
#Q8 (school type)
summaries_data$Q8_recode <- factor(summaries_data$Q8_recode, levels = c(1, 2, 3, 4), labels = c("local authority", "academy", "free school", "independent school"))
#testplot <- ggplot(summaries_data, aes(x = Q8_recode, y = Q22_avg)) + geom_bar(stat = "identity")
#testplot
Q22_by_Q8visualization <- ggplot(summaries_data, aes(x = Q8_recode, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q8visualization
#Q9 (school size)
summaries_data$Q9_recode <- factor(summaries_data$Q9_recode, levels = c(1, 2, 3), labels = c("1-9", "10-25", "25-100"))
Q22_by_Q9visualization <- ggplot(summaries_data, aes(x = Q9_recode, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q9visualization
#Q10 (school location)
# Not sure what all the options are?
#Q12-14 (school's official religion)
summaries_data$Q12 <- factor(summaries_data$Q12, levels = c("No", "Yes"), labels = c("No", "Yes"))
Q22_by_Q12visualization <- ggplot(summaries_data, aes(x = Q12, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q12visualization
#Q15-16 (school's informal religion)
summaries_data$Q15 <- factor(summaries_data$Q15, levels = c("No", "Yes"), labels = c("No", "Yes"))
Q22_by_Q15visualization <- ggplot(summaries_data, aes(x = Q15, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q15visualization
#Q21 (respondent personal religious background)
summaries_data$Q21_binaryrecode <- factor(summaries_data$Q21_binaryrecode, levels = c(1, 2), labels = c("No", "Yes"))
Q22_by_Q21visualization <- ggplot(summaries_data, aes(x = Q21_binaryrecode, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q21visualization
###OR###
Q22_by_Q21visualization2 <- ggplot(summaries_data, aes(x = Q21, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q21visualization2
#Q4 (teacher's degree subject) - write-in...figure out how to sort
#Q18 (respondent gender)
Q22_by_Q18visualization <- ggplot(summaries_data, aes(x = Q18, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q18visualization
#Q19 (respondent ethnic self-desc)
Q22_by_Q19visualization <- ggplot(summaries_data, aes(x = Q19, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar") + coord_flip()
Q22_by_Q19visualization
```
```{r Plots Q23}
# Q23
#Q8 (school type)
summaries_data$Q8_recode <- factor(summaries_data$Q8_recode, levels = c(1, 2, 3, 4), labels = c("local authority", "academy", "free school", "independent school"))
#split??
#Q23_by_Q8visualization <- ggplot(summaries_data, aes(x = Q8_recode, y = cbind(Q23_1, Q23_2))) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q8visualization1 <- ggplot(summaries_data, aes(x = Q8_recode, y = Q23_1)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q8visualization1
Q23_by_Q8visualization2 <- ggplot(summaries_data, aes(x = Q8_recode, y = Q23_2)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q8visualization2
#Q9 (school size)
summaries_data$Q9_recode <- factor(summaries_data$Q9_recode, levels = c(1, 2, 3), labels = c("1-9", "10-25", "25-100"))
Q23_by_Q9visualization1 <- ggplot(summaries_data, aes(x = Q9_recode, y = Q23_1)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q9visualization1
Q23_by_Q9visualization2 <- ggplot(summaries_data, aes(x = Q9_recode, y = Q23_2)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q9visualization2
#Q10 (school location)
# Not sure what all the options are?
#Q12-14 (school's official religion)
summaries_data$Q12 <- factor(summaries_data$Q12, levels = c("No", "Yes"), labels = c("No", "Yes"))
Q23_by_Q12visualization1 <- ggplot(summaries_data, aes(x = Q12, y = Q23_1)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q12visualization1
Q23_by_Q12visualization2 <- ggplot(summaries_data, aes(x = Q12, y = Q23_2)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q12visualization2
#Q15-16 (school's informal religion)
summaries_data$Q15 <- factor(summaries_data$Q15, levels = c("No", "Yes"), labels = c("No", "Yes"))
Q23_by_Q15visualization1 <- ggplot(summaries_data, aes(x = Q15, y = Q23_1)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q15visualization1
Q23_by_Q15visualization2 <- ggplot(summaries_data, aes(x = Q15, y = Q23_2)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q15visualization2
#Q21 (respondent personal religious background)
summaries_data$Q21_binaryrecode <- factor(summaries_data$Q21_binaryrecode, levels = c(1, 2), labels = c("No", "Yes"))
Q23_by_Q21visualization1 <- ggplot(summaries_data, aes(x = Q21_binaryrecode, y = Q23_1)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q21visualization1
Q23_by_Q21visualization2 <- ggplot(summaries_data, aes(x = Q21_binaryrecode, y = Q23_2)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q21visualization2
###OR###
#Q22_by_Q21visualization2 <- ggplot(summaries_data, aes(x = Q21, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
#Q22_by_Q21visualization2
#Q4 (teacher's degree subject) - write-in...figure out how to sort
#Q18 (respondent gender)
Q23_by_Q18visualization1 <- ggplot(summaries_data, aes(x = Q18, y = Q23_1)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q18visualization1
Q23_by_Q18visualization2 <- ggplot(summaries_data, aes(x = Q18, y = Q23_2)) + stat_summary(fun = "mean", geom = "bar")
Q23_by_Q18visualization2
#Q19 (respondent ethnic self-desc)
Q23_by_Q19visualization1 <- ggplot(summaries_data, aes(x = Q19, y = Q23_1)) + stat_summary(fun = "mean", geom = "bar") + coord_flip()
Q23_by_Q19visualization1
Q23_by_Q19visualization2 <- ggplot(summaries_data, aes(x = Q19, y = Q23_2)) + stat_summary(fun = "mean", geom = "bar") + coord_flip()
Q23_by_Q19visualization2
```
```{r Plots Q24}
# Q24
```
```{r Plots Q25}
# Q25
```
```{r Plots Q26}
# Q26
```
```{r Plots Q27}
# Q27
#Q8 (school type)
summaries_data$Q8_recode <- factor(summaries_data$Q8_recode, levels = c(1, 2, 3, 4), labels = c("local authority", "academy", "free school", "independent school"))
#testplot <- ggplot(summaries_data, aes(x = Q8_recode, y = Q22_avg)) + geom_bar(stat = "identity")
#testplot
Q22_by_Q8visualization <- ggplot(summaries_data, aes(x = Q8_recode, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q8visualization
#Q9 (school size)
summaries_data$Q9_recode <- factor(summaries_data$Q9_recode, levels = c(1, 2, 3), labels = c("1-9", "10-25", "25-100"))
Q22_by_Q9visualization <- ggplot(summaries_data, aes(x = Q9_recode, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q9visualization
#Q10 (school location)
# Not sure what all the options are?
#Q12-14 (school's official religion)
summaries_data$Q12 <- factor(summaries_data$Q12, levels = c("No", "Yes"), labels = c("No", "Yes"))
Q22_by_Q12visualization <- ggplot(summaries_data, aes(x = Q12, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q12visualization
#Q15-16 (school's informal religion)
summaries_data$Q15 <- factor(summaries_data$Q15, levels = c("No", "Yes"), labels = c("No", "Yes"))
Q22_by_Q15visualization <- ggplot(summaries_data, aes(x = Q15, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q15visualization
#Q21 (respondent personal religious background)
summaries_data$Q21_binaryrecode <- factor(summaries_data$Q21_binaryrecode, levels = c(1, 2), labels = c("No", "Yes"))
Q22_by_Q21visualization <- ggplot(summaries_data, aes(x = Q21_binaryrecode, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q21visualization
###OR###
Q22_by_Q21visualization2 <- ggplot(summaries_data, aes(x = Q21, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q21visualization2
#Q4 (teacher's degree subject) - write-in...figure out how to sort
#Q18 (respondent gender)
Q22_by_Q18visualization <- ggplot(summaries_data, aes(x = Q18, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q18visualization
#Q19 (respondent ethnic self-desc)
Q22_by_Q19visualization <- ggplot(summaries_data, aes(x = Q19, y = Q22_avg)) + stat_summary(fun = "mean", geom = "bar")
Q22_by_Q19visualization
```
## Correlation testing: