diff --git a/.RData b/.RData index 318f8b5..07b203d 100644 Binary files a/.RData and b/.RData differ diff --git a/.Rhistory b/.Rhistory index fbfd1f0..16b713b 100644 --- a/.Rhistory +++ b/.Rhistory @@ -1,86 +1,3 @@ -#High interest in Sociology -hSocTheo <- mean(as.numeric(Soc_subset_Low$InterestedinstudyingTheology), na.rm = TRUE) -## Religious Studies Interest -#Low interest in Sociology -mean(as.numeric(Soc_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE) -#High interest in Sociology -mean(as.numeric(Soc_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE) -### Philosophy ### -Philos_subset_Low <- TSR_data[TSR_data$GoodunderstandingofPhilosophy < 3 & TSR_data$GoodunderstandingofPhilosophy != 0, ] -Philos_subset_High <- TSR_data[TSR_data$GoodunderstandingofPhilosophy > 3, ] -## Theology Knowledge -#Low knowledge in Philosophy -mean(as.numeric(Philos_subset_Low$GoodunderstandingofTheology), na.rm = TRUE) -#High knowledge in Philosophy -mean(as.numeric(Philos_subset_Low$GoodunderstandingofTheology), na.rm = TRUE) -## Religious Studies Knowledge -#Low knowledge in Philosophy -mean(as.numeric(Philos_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE) -#High knowledge in Philosophy -mean(as.numeric(Philos_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE) -## Religious Studies Knowledge -#Low knowledge in Philosophy -mean(as.numeric(Philos_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE) -#High knowledge in Philosophy -mean(as.numeric(Philos_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE) -```{r Sociology} -### Sociology ### -Soc_subset_Low <- TSR_data[TSR_data$GoodunderstandingofSociology < 3 & TSR_data$GoodunderstandingofSociology != 0, ] -Soc_subset_High <- TSR_data[TSR_data$GoodunderstandingofSociology > 3, ] -## Theology knowledge -#Low knowledge in Sociology -mean(as.numeric(Soc_subset_Low$GoodunderstandingofTheology), na.rm = TRUE) -#High knowledge in Sociology -mean(as.numeric(Soc_subset_Low$GoodunderstandingofTheology), na.rm = TRUE) -## Religious Studies knowledge -#Low knowledge in Sociology -mean(as.numeric(Soc_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE) -#High knowledge in Sociology -mean(as.numeric(Soc_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE) -## Religious Studies knowledge -#Low knowledge in Sociology -mean(as.numeric(Soc_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE) -#High knowledge in Sociology -mean(as.numeric(Soc_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE) -```{r Psychology} -### Psychology ### -Psych_subset_Low <- TSR_data[TSR_data$GoodunderstandingofPsychology < 3 & TSR_data$GoodunderstandingofPsychology != 0, ] -Psych_subset_High <- TSR_data[TSR_data$GoodunderstandingofPsychology > 3, ] -## Theology knowledge -#Low knowledge in Psychology -mean(as.numeric(Psych_subset_Low$GoodunderstandingofTheology), na.rm = TRUE) -#High knowledge in Psychology -mean(as.numeric(Psych_subset_Low$GoodunderstandingofTheology), na.rm = TRUE) -## Religious Studies knowledge -#Low knowledge in Psychology -mean(as.numeric(Psych_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE) -#High knowledge in Psychology -mean(as.numeric(Psych_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE) -### History ### -Hist_subset_Low <- TSR_data[TSR_data$GoodunderstandingofHistory < 3 & TSR_data$GoodunderstandingofHistory != 0, ] -Hist_subset_High <- TSR_data[TSR_data$GoodunderstandingofHistory > 3, ] -require(devtools) -library(ggplot2) -require(ggplot2) -require(usethis) -require(devtools) -require(likert) -TSR_data <- read.csv("./data/TSR data complete.csv") -subject_data <- read.csv("./data/Subject data.csv") -TSR_data$Age <- factor(TSR_data$Age, levels = c(1, 2, 3, 4, 5, 6, 7, 8), labels = c("15 or under", "16", "17", "18", "19", "20", "21 or over", "Prefer not to say")) -age_pie <- pie(table(TSR_data$Age)) -# Load RColorBrewer -# install.packages("RColorBrewer") -library(RColorBrewer) -# Define colour palettes for plots below -coul3 <- brewer.pal(3, "RdYlBu") # Using RdYlBu range to generate 3 colour palette: https://colorbrewer2.org/#type=diverging&scheme=RdYlBu&n=5 -TSR_data$Age <- factor(TSR_data$Age, levels = c(1, 2, 3, 4, 5, 6, 7, 8), labels = c("15 or under", "16", "17", "18", "19", "20", "21 or over", "Prefer not to say")) -age_pie <- pie(table(TSR_data$Age), col=coul3) -TSR_data$Age <- factor(TSR_data$Age, levels = c(1, 2, 3, 4, 5, 6, 7, 8), labels = c("15 or under", "16", "17", "18", "19", "20", "21 or over", "Prefer not to say")) -View(TSR_data) -TSR_data <- read.csv("./data/TSR data complete.csv") -View(TSR_data) -TSR_data$Age <- factor(TSR_data$Age, levels = c(1, 2, 3, 4, 5, 6, 7, 8), labels = c("15 or under", "16", "17", "18", "19", "20", "21 or over", "Prefer not to say")) age_pie <- pie(table(TSR_data$Age), col=coul3) TSR_data$MOST.RECENT.year.of.study <- factor(TSR_data$MOST.RECENT.year.of.study, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9), labels = c("Year 11/S4/Year 12(NI)", "Year 12/S5/Year 13(NI)", "Year 13/S6/Year 14(NI)", "I am currently on a gap year", "I am currently on an undergraduate/HE college course", "I am in full-time employment", "I am unemployed", "Other", "Prefer not to say")) TSR_data$Age <- age_pie <- pie(table(factor(TSR_data$Age, levels = c(1, 2, 3, 4, 5, 6, 7, 8), labels = c("15 or under", "16", "17", "18", "19", "20", "21 or over", "Prefer not to say"))), col=coul3) @@ -510,3 +427,86 @@ library(scales) # Used for adding percentages to bar charts Religious_affiliation_bar3 <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_religion, label=scales::percent(pct))) + geom_bar() + coord_flip() Religious_affiliation_bar3 + labs(title = "Respondent religious self-identification, positive sentiment towards rs", x = "", y = "") Religious_affiliation_bar3 <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_religion) + geom_bar() + geom_text(label=scales::percent(pct))) + coord_flip() +knitr::opts_chunk$set(echo = TRUE) +library(ggplot2) +library(devtools) +library(usethis) +library(devtools) +library(likert) +# Load RColorBrewer +# install.packages("RColorBrewer") +library(RColorBrewer) +library("stringr") # Load stringr package, used for wrapping label text in plots +library(dplyr) # Used for filtering below +library(scales) # Used for adding percentages to bar charts +# Define colour palettes for plots below +coul3 <- brewer.pal(3, "RdYlBu") # Using RdYlBu range to generate 3 colour palette: https://colorbrewer2.org/#type=diverging&scheme=RdYlBu&n=5 +TSR_data <- read.csv("./data/TSR data complete.csv") +subject_data <- read.csv("./data/Subject data.csv") +# Set up local workspace (as needed): +if (dir.exists("data") == FALSE) { +dir.create("data") +} +if (dir.exists("figures") == FALSE) { +dir.create("figures") +} +if (dir.exists("derivedData") == FALSE) { +dir.create("derivedData") +} +# Set up local workspace, as needed: +if (dir.exists("data") == FALSE) { +dir.create("data") +} +if (dir.exists("figures") == FALSE) { +dir.create("figures") +} +if (dir.exists("derivedData") == FALSE) { +dir.create("derivedData") +} +TSR_data_theology_positive_summaries_ethnicity <- factor(TSR_data_theology_positive$Ethnicity, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ,18, 19), labels = c("Arab", "Indian", "Pakistani", "Bangladeshi", "Chinese", "Any other Asian background", "Black - African", "Black - Caribbean", "Any other Black background", "Mixed - White and Black Caribbean", "Mixed - White and Black African", "Mixed - White and Black Asian", "Any other Mixed/Multiple Ethnic background", "White - British", "White - Irish", "Gypsy or Irish Traveller", "Any other White background", "Other Ethnic group", "Prefer not to say")) +TSR_data_theology_positive_summaries_ethnicity <- str_wrap(TSR_data_summaries_ethnicity, width = 30) +TSR_data_rs_positive_summaries_ethnicity <- factor(TSR_data_rs_positive$Ethnicity, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ,18, 19), labels = c("Arab", "Indian", "Pakistani", "Bangladeshi", "Chinese", "Any other Asian background", "Black - African", "Black - Caribbean", "Any other Black background", "Mixed - White and Black Caribbean", "Mixed - White and Black African", "Mixed - White and Black Asian", "Any other Mixed/Multiple Ethnic background", "White - British", "White - Irish", "Gypsy or Irish Traveller", "Any other White background", "Other Ethnic group", "Prefer not to say")) +TSR_data_rs_positive_summaries_ethnicity <- str_wrap(TSR_data_summaries_ethnicity, width = 30) +TSR_data__theology_positive_summaries_gender <- factor(TSR_data_theology_positive$Gender, levels = c(1, 2, 3, 4), labels = c("Male", "Female", "I identify my gender in another way", "Prefer not to say")) +# JK note: using stringr here to wrap axis titles +TSR_data__theology_positive_summaries_gender <- str_wrap(TSR_data__theology_positive_summaries_gender, width = 10) +TSR_data_rs_positive_summaries_gender <- factor(TSR_data_rs_positive$Gender, levels = c(1, 2, 3, 4), labels = c("Male", "Female", "I identify my gender in another way", "Prefer not to say")) +# JK note: using stringr here to wrap axis titles +TSR_data_rs_positive_summaries_gender <- str_wrap(TSR_data_rs_positive_summaries_gender, width = 10) +gender_bar2 <- ggplot(TSR_data_theology_positive, aes(TSR_data__theology_positive_summaries_gender)) + geom_bar() +gender_bar2 + labs(title = "Respondent gender self-identification, theology positive", x = "", y = "") +gender_bar2 + labs(title = "Respondent gender self-identification, theology positive", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_gender2.png") +gender_bar3 <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_gender)) + geom_bar() +gender_bar3 + labs(title = "Respondent gender self-identification, rs positive", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_gender3.png") +data_summaries_theology_positive_ethnicity <- ggplot(TSR_data_theology_positive, aes(TSR_data_theology_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_theology_positive_ethnicity + labs(title = "Respondent ethnic self-identification, theology positive", x = "", y = "") +data_summaries_theology_positive_ethnicity + labs(title = "Respondent ethnic self-identification, theology positive", x = "", y = "") +data_summaries_theology_positive_ethnicity <- ggplot(TSR_data_theology_positive, aes(TSR_data_theology_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_theology_positive_ethnicity + labs(title = "Respondent ethnic self-identification, theology positive", x = "", y = "") +data_summaries_theology_positive_ethnicity + labs(title = "Respondent ethnic self-identification", x = "", y = "") +TSR_data_rs_negative_summaries_religion <- factor(TSR_data_rs_negative$ReligiousAffliation, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), labels = c("Agnostic", "Atheist", "Baha'i", "Buddhist", "Christian", "Confucian", "Jain", "Jewish", "Hindu", "Indigenous Traditional Religious", "Muslim", "Pagan", "Shinto", "Sikh", "Spiritual but not religious", "Zoroastrian", "No religion", "Prefer not to say", "Other")) +TSR_data_theology_positive_summaries_ethnicity <- factor(TSR_data_theology_positive$Ethnicity, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ,18, 19), labels = c("Arab", "Indian", "Pakistani", "Bangladeshi", "Chinese", "Any other Asian background", "Black - African", "Black - Caribbean", "Any other Black background", "Mixed - White and Black Caribbean", "Mixed - White and Black African", "Mixed - White and Black Asian", "Any other Mixed/Multiple Ethnic background", "White - British", "White - Irish", "Gypsy or Irish Traveller", "Any other White background", "Other Ethnic group", "Prefer not to say")) +TSR_data_theology_positive_summaries_ethnicity <- str_wrap(TSR_data_theology_positive_summaries_ethnicity, width = 30) +TSR_data_rs_positive_summaries_ethnicity <- factor(TSR_data_rs_positive$Ethnicity, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ,18, 19), labels = c("Arab", "Indian", "Pakistani", "Bangladeshi", "Chinese", "Any other Asian background", "Black - African", "Black - Caribbean", "Any other Black background", "Mixed - White and Black Caribbean", "Mixed - White and Black African", "Mixed - White and Black Asian", "Any other Mixed/Multiple Ethnic background", "White - British", "White - Irish", "Gypsy or Irish Traveller", "Any other White background", "Other Ethnic group", "Prefer not to say")) +TSR_data_rs_positive_summaries_ethnicity <- str_wrap(TSR_data_rs_positive_summaries_ethnicity, width = 30) +TSR_data_rs_positive_summaries_ethnicity <- str_wrap(TSR_data_rs_positive_summaries_ethnicity, width = 30) +data_summaries_rs_positive_ethnicity <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_ethnicity + labs(title = "Respondent ethnic self-identification", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_ethnicity3.png") +data_summaries_theology_positive_ethnicity <- ggplot(TSR_data_theology_positive, aes(TSR_data_theology_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_theology_positive_ethnicity + labs(title = "Respondent ethnic self-identification", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_ethnicity2.png") +data_summaries_theology_positive_ethnicity <- ggplot(TSR_data_theology_positive, aes(TSR_data_theology_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_theology_positive_ethnicity + labs(title = "Respondent ethnic self-identification - theology positive", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_ethnicity2.png") +data_summaries_rs_positive_ethnicity <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_ethnicity + labs(title = "Respondent ethnic self-identification - religion positive", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_ethnicity3.png") diff --git a/tsr_survey_analysis.Rmd b/tsr_survey_analysis.Rmd index da3d496..2d17f0f 100644 --- a/tsr_survey_analysis.Rmd +++ b/tsr_survey_analysis.Rmd @@ -13,9 +13,9 @@ library(likert) # Load RColorBrewer # install.packages("RColorBrewer") library(RColorBrewer) -library("stringr") # Load stringr package, used for wrapping label text in plots -library(dplyr) # Used for filtering below -library(scales) # Used for adding percentages to bar charts +library("stringr") # Load stringr package, used for wrapping label text in plots +library(dplyr) # Used for filtering below +library(scales) # Used for adding percentages to bar charts # Define colour palettes for plots below coul3 <- brewer.pal(3, "RdYlBu") # Using RdYlBu range to generate 3 colour palette: https://colorbrewer2.org/#type=diverging&scheme=RdYlBu&n=5 @@ -23,7 +23,7 @@ coul3 <- brewer.pal(3, "RdYlBu") # Using RdYlBu range to generate 3 colour palet TSR_data <- read.csv("./data/TSR data complete.csv") subject_data <- read.csv("./data/Subject data.csv") -# Set up local workspace: +# Set up local workspace, as needed: if (dir.exists("data") == FALSE) { dir.create("data") } @@ -100,6 +100,23 @@ TSR_data_rs_positive_summaries_religion <- factor(TSR_data_rs_positive$Religious TSR_data_rs_negative_summaries_religion <- factor(TSR_data_rs_negative$ReligiousAffliation, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19), labels = c("Agnostic", "Atheist", "Baha'i", "Buddhist", "Christian", "Confucian", "Jain", "Jewish", "Hindu", "Indigenous Traditional Religious", "Muslim", "Pagan", "Shinto", "Sikh", "Spiritual but not religious", "Zoroastrian", "No religion", "Prefer not to say", "Other")) +TSR_data_theology_positive_summaries_ethnicity <- factor(TSR_data_theology_positive$Ethnicity, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ,18, 19), labels = c("Arab", "Indian", "Pakistani", "Bangladeshi", "Chinese", "Any other Asian background", "Black - African", "Black - Caribbean", "Any other Black background", "Mixed - White and Black Caribbean", "Mixed - White and Black African", "Mixed - White and Black Asian", "Any other Mixed/Multiple Ethnic background", "White - British", "White - Irish", "Gypsy or Irish Traveller", "Any other White background", "Other Ethnic group", "Prefer not to say")) + +TSR_data_theology_positive_summaries_ethnicity <- str_wrap(TSR_data_theology_positive_summaries_ethnicity, width = 30) + +TSR_data_rs_positive_summaries_ethnicity <- factor(TSR_data_rs_positive$Ethnicity, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ,18, 19), labels = c("Arab", "Indian", "Pakistani", "Bangladeshi", "Chinese", "Any other Asian background", "Black - African", "Black - Caribbean", "Any other Black background", "Mixed - White and Black Caribbean", "Mixed - White and Black African", "Mixed - White and Black Asian", "Any other Mixed/Multiple Ethnic background", "White - British", "White - Irish", "Gypsy or Irish Traveller", "Any other White background", "Other Ethnic group", "Prefer not to say")) + +TSR_data_rs_positive_summaries_ethnicity <- str_wrap(TSR_data_rs_positive_summaries_ethnicity, width = 30) + +TSR_data__theology_positive_summaries_gender <- factor(TSR_data_theology_positive$Gender, levels = c(1, 2, 3, 4), labels = c("Male", "Female", "I identify my gender in another way", "Prefer not to say")) +# JK note: using stringr here to wrap axis titles +TSR_data__theology_positive_summaries_gender <- str_wrap(TSR_data__theology_positive_summaries_gender, width = 10) + +TSR_data_rs_positive_summaries_gender <- factor(TSR_data_rs_positive$Gender, levels = c(1, 2, 3, 4), labels = c("Male", "Female", "I identify my gender in another way", "Prefer not to say")) +# JK note: using stringr here to wrap axis titles +TSR_data_rs_positive_summaries_gender <- str_wrap(TSR_data_rs_positive_summaries_gender, width = 10) + + # Calculate graphs Religious_affiliation_bar <- ggplot(TSR_data, aes(TSR_data_summaries_religion)) + geom_bar() + coord_flip() @@ -109,7 +126,7 @@ ggsave("figures/TSR_data_summaries_religion.png") # Additional graphs for theology/rs positive sentiment cohorts -# Theology +# Theology - religious identification # JK note: need to add percentages to each line, as per https://stackoverflow.com/questions/52373049/display-percentage-on-ggplot-bar-chart-in-r @@ -125,14 +142,36 @@ Religious_affiliation_bar3 + labs(title = "Respondent religious self-identificat # save to png file for reports ggsave("figures/TSR_data_summaries_religion_rspositive.png") -irisNew <- iris %>% group_by(Species) %>% - summarize(count = n()) %>% # count records by species - mutate(pct = count/sum(count)) # find percent of total +# Theology positive - gender + +gender_bar2 <- ggplot(TSR_data_theology_positive, aes(TSR_data_theology_positive_summaries_gender)) + geom_bar() +gender_bar2 + labs(title = "Respondent gender self-identification, theology positive", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_gender2.png") + +# Religion positive - gender + +gender_bar3 <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_gender)) + geom_bar() +gender_bar3 + labs(title = "Respondent gender self-identification, rs positive", x = "", y = "") +# save to png file for reports +ggsave("figures/TSR_data_summaries_gender3.png") + +# Theology positive - ethnicity + +data_summaries_theology_positive_ethnicity <- ggplot(TSR_data_theology_positive, aes(TSR_data_theology_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_theology_positive_ethnicity + labs(title = "Respondent ethnic self-identification - theology positive", x = "", y = "") + +# save to png file for reports +ggsave("figures/TSR_data_summaries_ethnicity2.png") + +# Religion positive - ethnicity + +data_summaries_rs_positive_ethnicity <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_ethnicity)) + geom_bar() + xlab(NULL) + coord_flip() +data_summaries_ethnicity + labs(title = "Respondent ethnic self-identification - religion positive", x = "", y = "") + +# save to png file for reports +ggsave("figures/TSR_data_summaries_ethnicity3.png") -ggplot(irisNew, aes(Species, pct, fill = Species)) + - geom_bar(stat='identity') + - geom_text(aes(label=scales::percent(pct)), position = position_stack(vjust = .5))+ - scale_y_continuous(labels = scales::percent) ``` # Visualisations of LIKERT responses (RH):