---
title: "RMarkdown Admissions_Survey2021"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(usethis)
library(devtools)
library(likert)
library(RColorBrewer)
library("readxl")
library(haven)

# 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")
admissions_data <- read_excel("./data/TSR_data_numbers.xlsx", sheet = "Raw data - completes")

# Set up local workspace, as needed:

if (dir.exists("data") == FALSE) {
  dir.create("data") 
}

# These paths are excluded from github as it is best practice for end-user to generate their own

if (dir.exists("figures") == FALSE) {
  dir.create("figures") 
}
if (dir.exists("derivedData") == FALSE) {
  dir.create("derivedData")
}

# Refactor data
q2_labels <- c("15 or under" = 1, "16" = 2, "17" = 3, "18" = 4, "19" = 5, "20" = 6, "21 or over" = 7, "Prefer not to say" = 8)
admissions_data$Q2 <- labelled(admissions_data$Q2, q2_labels, label = "How old are you?")

admissions_data$Q3 <- labelled(admissions_data$Q3, c("Year 11/S4/Year 12(NI)" = 1, "Year 12/S5/Year 13(NI)" = 2, "Year 13/S6/Year 14(NI)" = 3, "I am currently on a gap year" = 4, "I am currently on an undergraduate/HE college course" = 5, "I am in full-time employment" = 6, "I am unemployed" = 7, "Other" = 8, "Prefer not to say" = 9), label = "Which of the following best describes your MOST RECENT year of study?")

admissions_data$Q4 <- labelled(admissions_data$Q4, c("Yes, definitely" = 1, "Yes, probably" = 2, "I haven’t ruled it out" = 3), label = "Are you considering or planning to go to university in the future?")

common_labels <- c(
  "Strongly agree" = 1,
  "Agree" = 2,
  "Neither/Nor" = 3,
  "Disagree" = 4,
  "Strongly disagree" = 5,
  "Prefer not to say" = 0
)

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q5_")), ~ labelled(., common_labels, label = "I have a good understanding of what this subject involves"))

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q6_")), ~ labelled(., common_labels, label = "I would be interested in studying this subject at University"))

common_labels2 <- c(
  "Good employability prospects" = 1,
  NULL = 2,
  NULL = 3,
  NULL = 4,
  "Poor employability prospects" = 5,
  "Prefer not to say" = 0
)

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q7_")), ~ labelled(., common_labels2, label = "This subject has… employability prospects"))

admissions_data$Q8 <- labelled(admissions_data$Q8, c("Theology is a subject for religious people" = 1, NULL = 2, NULL = 3, NULL = 4, "Theology is a subject for religious and non-religious people" = 5, "Prefer not to say" = 0), label = "Thinking about Theology, please select an option on the scale from 1 to 5 which best represents your opinion")

admissions_data$Q9 <- labelled(admissions_data$Q9, c("Religion is a subject for religious people" = 1, NULL = 2, NULL = 3, NULL = 4, "Religion is a subject for religious and non-religious people" = 5, "Prefer not to say" = 0), label = "Thinking about Religion, please select an option on the scale from 1 to 5 which best represents your opinion")

common_labels3 <- c(
  "Psychology" = 1, "Arts" = 2, "Sociology" = 3, "Politics" = 4, "History" = 5, "Philosophy" = 6, "Ethics" = 7, "Archaeology" = 8, "Textual studies" = 9, "Literature" = 10, "Law" = 11, "Economics" = 12, "Science" = 13, "Prefer not to say" = 0)

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q10_")), ~ labelled(., common_labels3, label = "I think that a theology degree would include..."))

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q11_")), ~ labelled(., common_labels3, label = "I think that a religious studies degree would include..."))

common_labels4 <- c(
  "Politics" = 1, "History" = 2, "Ethics" = 3, "Theology" = 4, "Religion" = 5, "Law" = 6, "Economics" = 7, "Maths" = 8, "Logic" = 9, "Prefer not to say" = 0)

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q12_")), ~ labelled(., common_labels4, label = "I think that a philosophy degree would include..."))

common_labels5 <- c("Yes" = 1, "No" = 2, "Prefer not to say" = 0)

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q13")), ~ labelled(., common_labels5, label = "Are you currently studying A level Religious Studies, or intending to?"))

admissions_data <- admissions_data %>%
  mutate_at(vars(starts_with("Q14")), ~ labelled(., common_labels5, label = "Are you studying or did you previously study GCSE Religious Studies?"))

admissions_data$Q16 <- labelled(admissions_data$Q16, c("Male"=1, "Female"=2, "I identify my gender in another way"=3, "Prefer not to say"=4), label = "I identify my gender as…")

admissions_data$Q17 <- labelled(admissions_data$Q17, c("Arab"=1, "Indian"=2, "Pakistani"=3, "Bangladeshi"=4, "Chinese"=5, "Any other Asian background"=6, "Black - African"=7, "Black - Caribbean"=8, "Any other Black background"=9, "Mixed - White and Black Caribbean"=10, "Mixed - White and Black African"=11, "Mixed - White and Black Asian"=12, "Any other Mixed/Multiple Ethnic background"=13, "White - British"=14, "White - Irish"=15, "Gypsy or Irish Traveller"=16, "Any other White background"=17, "Other Ethnic group"=18, "Prefer not to say OR Other"=0), label = "What is your ethnic group?")

admissions_data$Q18 <- labelled(admissions_data$Q18, c("Agnostic"=1, "Atheist"=2, "Baha'i"=3, "Buddhist"=4, "Christian"=5, "Confucian"=6, "Jain"=7, "Jewish"=8, "Hindu"=9, "Indigenous Traditional Religious"=10, "Muslim"=11, "Pagan"=12, "Shinto"=13, "Sikh"=14, "Spiritual but not religious"=15, "Zoroastrian"=16, "No religion"=17, "Prefer not to say OR Other"=0), label = "What is your religion?")

# Create bins:

# For Q5 - understanding

admissions_data <- admissions_data %>%
  mutate(
    Q5_Theology = ifelse(Q5_Theology == 0, NA, Q5_Theology),
    understanding_theology_bin = case_when(
      Q5_Theology < 3 ~ "high",
      Q5_Theology > 3 ~ "low",
      Q5_Theology == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("low", "neutral", "high"))
  )
# For Q5 - understanding

admissions_data <- admissions_data %>%
  mutate(
    Q5_Religious_Studies = ifelse(Q5_Religious_Studies == 0, NA, Q5_Religious_Studies),
    understanding_religion_bin = case_when(
      Q5_Religious_Studies < 3 ~ "high",
      Q5_Religious_Studies > 3 ~ "low",
      Q5_Religious_Studies == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("low", "neutral", "high"))
  )
# For Q6 - interest

admissions_data <- admissions_data %>%
  mutate(
    Q6_Theology = ifelse(Q6_Theology == 0, NA, Q6_Theology),
    interest_theology_bin = case_when(
      Q6_Theology < 3 ~ "high",
      Q6_Theology > 3 ~ "low",
      Q6_Theology == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("low", "neutral", "high"))
  )

# For Q6 - interest

admissions_data <- admissions_data %>%
  mutate(
    Q6_Religious_Studies = ifelse(Q6_Religious_Studies == 0, NA, Q6_Religious_Studies),
    interest_religion_bin = case_when(
      Q6_Religious_Studies < 3 ~ "high",
      Q6_Religious_Studies > 3 ~ "low",
      Q6_Religious_Studies == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("low", "neutral", "high"))
  )

# For Q7 - employability prospects

admissions_data <- admissions_data %>%
  mutate(
    Q7_Theology = ifelse(Q7_Theology == 0, NA, Q7_Theology),
    employability_optimism_theology_bin = case_when(
      Q7_Theology < 3 ~ "high",
      Q7_Theology > 3 ~ "low",
      Q7_Theology == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("low", "neutral", "high"))
  )

# For Q7 - employability prospects

admissions_data <- admissions_data %>%
  mutate(
    Q7_Religious_Studies = ifelse(Q7_Religious_Studies == 0, NA, Q7_Religious_Studies),
    employability_optimism_religion_bin = case_when(
      Q7_Religious_Studies < 3 ~ "high",
      Q7_Religious_Studies > 3 ~ "low",
      Q7_Religious_Studies == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("low", "neutral", "high"))
  )

# For Q8 - employability prospects

admissions_data <- admissions_data %>%
  mutate(
    Q8 = ifelse(Q8 == 6, NA, Q8),
    theology_for_bin = case_when(
      Q8 < 3 ~ "religious",
      Q8 > 3 ~ "all_people",
      Q8 == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("all_people", "neutral", "religious"))
  )

admissions_data <- admissions_data %>%
  mutate(
    Q9 = ifelse(Q9 == 6, NA, Q9),
    religion_for_bin = case_when(
      Q9 < 3 ~ "religious",
      Q9 > 3 ~ "all_people",
      Q9 == 3 ~ "neutral",
      TRUE ~ NA
    ) %>% factor(levels = c("all_people", "neutral", "religious"))
  )

# Q17 non-white / white ethnicity bins
admissions_data <- admissions_data %>%
  mutate(
    Q17 = ifelse(Q17 == 0, NA, Q17),
    ethnicity_bin = case_when(
      Q17 > 13 | Q17 < 18 ~ "white",
      TRUE ~ "non-white"
    ) %>% factor(levels = c("white", "non-white"))
  )

# Q18 non-religious / institutioal bins
admissions_data <- admissions_data %>%
  mutate(
      Q18 = ifelse(Q18 == 0, NA, Q18),
      religion_bin = case_when(
      Q18 %in% c(1, 2, 5, 17) ~ "non-religious",
      TRUE ~ "religious"
    ) %>% factor(levels = c("non-religious", "religious"))
  )

```

```{r correlations}
Q5_data <- select(admissions_data, Q5_Philosophy:Q5_Business)
cor(admissions_data$Q5_Philosophy, admissions_data$Q6_Philosophy)

```

# Basic demographic summary visualisations:
```{r demographic_summaries}

# 1. Calculate for age of respondent:

age <- factor(admissions_data$Q2), 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(admissions_data$Q2), col=coul3, cex = 0.8)
# JK note: adding in a bar chart here, as according to the interwebs it's (apparently?) more accurate to visualise than bar charts

ggplot(admissions_data, aes(factor(Q2))) + 
  geom_bar() +
  geom_text(stat = "count", aes(label = after_stat(count)), vjust = -0.5) +
  labs(title = "Respondent Age Distribution", x = "Age", y = "") +
  scale_x_discrete(labels = labels(q2_labels))

# save to png file for reports
ggsave("figures/TSR_data_summaries_age.png")
```

```{r}
# 2. Calculate for year of study:

TSR_data_summaries_yos <- factor(TSR_data$MOSTRECENTyearofstudy, 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"))

data_summaries_yos <- ggplot(TSR_data, aes(TSR_data_summaries_yos)) + geom_bar()
data_summaries_yos + labs(title = "Respondent Most Recent Year of Study", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_summaries_yos.png")
```

```{r}
# 3. Gender identity:

TSR_data_summaries_gender <- factor(TSR_data$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_summaries_gender <- str_wrap(TSR_data_summaries_gender, width = 10)

data_summaries_gender <- ggplot(TSR_data, aes(TSR_data_summaries_gender)) + geom_bar()
data_summaries_gender + labs(title = "Respondent gender self-identification", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_summaries_gender.png")

# 4. Ethnic self-identification:

TSR_data_summaries_ethnicity <- factor(TSR_data$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_summaries_ethnicity <- str_wrap(TSR_data_summaries_ethnicity, width = 30)

data_summaries_ethnicity <- ggplot(TSR_data, aes(TSR_data_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_ethnicity.png")

# 5. Religion

TSR_data_summaries_religion <- factor(TSR_data$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"))

# Adding a subset for charting out composition of group which specifically marked positive sentiments wrt/ theology or religious studies

TSR_data_theology_positive <- filter(TSR_data, InterestedinstudyingTheology >= 4 & InterestedinstudyingTheology != 0)
TSR_data_theology_negative <- filter(TSR_data, InterestedinstudyingTheology <= 2 & InterestedinstudyingTheology != 0)

TSR_data_rs_positive <- filter(TSR_data, InterestedinstudyingReligiousStudies >= 4 & InterestedinstudyingReligiousStudies != 0)
TSR_data_rs_negative <- filter(TSR_data, InterestedinstudyingReligiousStudies <= 2 & InterestedinstudyingReligiousStudies != 0)

TSR_data_theology_positive_summaries_religion <- factor(TSR_data_theology_positive$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_negative_summaries_religion <- factor(TSR_data_theology_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_rs_positive_summaries_religion <- factor(TSR_data_rs_positive$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_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()
Religious_affiliation_bar + labs(title = "Respondent religious self-identification", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_summaries_religion.png")

# Additional graphs for theology/rs positive sentiment cohorts

# 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

Religious_affiliation_bar2 <- ggplot(TSR_data_theology_positive, aes(TSR_data_theology_positive_summaries_religion)) + geom_bar() + coord_flip()
Religious_affiliation_bar2 + labs(title = "Respondent religious self-identification, positive sentiment towards theology", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_summaries_religion_theologypositive.png")

# RS

Religious_affiliation_bar3 <- ggplot(TSR_data_rs_positive, aes(TSR_data_rs_positive_summaries_religion)) + geom_bar() + coord_flip()
Religious_affiliation_bar3 + labs(title = "Respondent religious self-identification, positive sentiment towards rs", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_summaries_religion_rspositive.png")

# 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")

```

# Visualisations of LIKERT responses (RH):
- For questions Q6 (subject interest) / Q5 (subject knowledge) / Q7 employability prospects: 
	- visualisation as summaries for all subjects LIKERT data as stacked bar chart (colours for bar segments from cool to warm)
	
```{r Visualization by Subject}

## Files have been reverse scored - Higher score now indicates more agreement

#Q5 Subject Knowledge/Understanding
subject_data$Subject <- factor(subject_data$Subject, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), labels = c("Philosophy", "Sociology", "Psychology", "History", "Ethics", "Theology", "Religious Studies", "Politics", "English", "Math", "Computer Science", "Business"))

understanding_mean <- aggregate(Understanding ~ Subject, data = subject_data, mean)

understanding_bar <- ggplot(understanding_mean, aes(x = Subject, y = Understanding)) + stat_summary(fun = "mean", geom = "bar") + coord_flip()
understanding_bar + labs(title = "I have a good understanding of what this subject involves?", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_subject_understanding.png")


#Q6 Subject Interest
interest_mean <- aggregate(Interest ~ Subject, data = subject_data, mean)

interest_bar <- ggplot(interest_mean, aes(x = Subject, y = Interest)) + stat_summary(fun = "mean", geom = "bar") + coord_flip()
interest_bar + labs(title = "I would be interested in studying this subject at University?", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_subject_interest.png")

#Q7 Employability Prospects

employability_mean <- aggregate(Employability ~ Subject, data = subject_data, mean)

employability_bar <- ggplot(employability_mean, aes(x = Subject, y = Employability)) + stat_summary(fun = "mean", geom = "bar") + coord_flip()
employability_bar + labs(title = "please rate ... employability prospects", x = "", y = "")
# save to png file for reports
ggsave("figures/TSR_data_subject_employability.png")
```

```{r}
### Likert Stacked Bar Chart ###

# Take selection of data re: understanding
Understanding_data <- TSR_data[, 6:17]
# Convert each column to factors
Understanding_data$GoodunderstandingofPhilosophy = factor(Understanding_data$GoodunderstandingofPhilosophy,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofSociology = factor(Understanding_data$GoodunderstandingofSociology,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofPsychology = factor(Understanding_data$GoodunderstandingofPsychology,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofHistory = factor(Understanding_data$GoodunderstandingofHistory,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofEthics = factor(Understanding_data$GoodunderstandingofEthics,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofTheology = factor(Understanding_data$GoodunderstandingofTheology,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofReligiousStudies = factor(Understanding_data$GoodunderstandingofReligiousStudies,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofPolitics = factor(Understanding_data$GoodunderstandingofPolitics,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofEnglish = factor(Understanding_data$GoodunderstandingofEnglish,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofMath = factor(Understanding_data$GoodunderstandingofMath,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofComputerScience = factor(Understanding_data$GoodunderstandingofComputerScience,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Understanding_data$GoodunderstandingofBusiness = factor(Understanding_data$GoodunderstandingofBusiness,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
names(Understanding_data) <- c("Philosophy", "Sociology", "Psychology", "History", "Ethics", "Theology", "Religious Studies", "Politics", "English", "Math", "Computer Science", "Business")

str(Understanding_data)
levels(Understanding_data)
summary(Understanding_data)
likert_test_understand <- likert(Understanding_data)
Understanding_data <- Q5_data
likert_test_understand <- likert(Q5_data)
plot(likert_test_understand)
# save to png file for reports
ggsave("figures/understanding_likert.png")
```

```{r}
Interest_data <- TSR_data[, 18:29]
# Convert each column to factors
Interest_data$InterestinstudyingPhilosophy = factor(Interest_data$InterestinstudyingPhilosophy,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestinstudyingSociaology = factor(Interest_data$InterestinstudyingSociaology,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinStudyingPsychology = factor(Interest_data$InterestedinStudyingPsychology,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingHistory = factor(Interest_data$InterestedinstudyingHistory,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingEthics = factor(Interest_data$InterestedinstudyingEthics,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingTheology = factor(Interest_data$InterestedinstudyingTheology,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingReligiousStudies = factor(Interest_data$InterestedinstudyingReligiousStudies,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingPolitics = factor(Interest_data$InterestedinstudyingPolitics,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingEnglish = factor(Interest_data$InterestedinstudyingEnglish,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingMath = factor(Interest_data$InterestedinstudyingMath,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingComputerScience = factor(Interest_data$InterestedinstudyingComputerScience,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Interest_data$InterestedinstudyingBusiness = factor(Interest_data$InterestedinstudyingBusiness,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
names(Interest_data) <- c("Philosophy", "Sociology", "Psychology", "History", "Ethics", "Theology", "Religious Studies", "Politics", "English", "Math", "Computer Science", "Business")

likert_test_interest <- likert(Interest_data)
plot(likert_test_interest)
# save to png file for reports
ggsave("figures/interest_likert.png")


Employability_data <- TSR_data[, 30:41]
# Convert each column to factors
Employability_data$Philosophyemployability = factor(Employability_data$Philosophyemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Sociologyemployability = factor(Employability_data$Sociologyemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$PsychologyEmployability = factor(Employability_data$PsychologyEmployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Historyemployability = factor(Employability_data$Historyemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Ethicsemployability = factor(Employability_data$Ethicsemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Theologyemployability = factor(Employability_data$Theologyemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$ReligiousStudiesemployability = factor(Employability_data$ReligiousStudiesemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Politicsemployability = factor(Employability_data$Politicsemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Englishemployability = factor(Employability_data$Englishemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Mathemployability = factor(Employability_data$Mathemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$ComputerScienceemployability = factor(Employability_data$ComputerScienceemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
Employability_data$Businessemployability = factor(Employability_data$Businessemployability,
                       ordered = TRUE,
                       levels = c("1", "2", "3", "4", "5")
                       )
names(Employability_data) <- c("Philosophy", "Sociology", "Psychology", "History", "Ethics", "Theology", "Religious Studies", "Politics", "English", "Math", "Computer Science", "Business")

likert_test_employability <- likert(Employability_data)
plot(likert_test_employability)
# save to png file for reports
ggsave("figures/employability_likert.png")


```

	- separate visualisation of summary data as pie chart only for 4 key subjects: Philosophy, Ethics, Theology, Religious Studies, but with data represented as aggregated "Positive" / "Negative" responses
	
```{r Visualization for 4 Key Subjects}
## Subset by "Positive" / "Negative"

# jk note: I've filled in the other fields just for fun

keysubjects_data <- subject_data[subject_data$Subject == "Philosophy" | subject_data$Subject == "Ethics" | subject_data$Subject == "Theology" | subject_data$Subject == "Religious Studies" | subject_data$Subject == "Sociology" | subject_data$Subject == "Psychology" | subject_data$Subject == "History" | subject_data$Subject == "Politics" | subject_data$Subject == "English" | subject_data$Subject == "Math" | subject_data$Subject == "Computer Science" | subject_data$Subject == "Business", ]

recode_interest <- ifelse(2 <= keysubjects_data$Interest & keysubjects_data$Interest >=4, "Positive", "Negative")

keysubjects_data <- cbind(keysubjects_data, recode_interest)
keysubjects_data$recode_interest <- factor(keysubjects_data$recode_interest)

interest_table <- table(keysubjects_data$recode_interest, keysubjects_data$Subject)
# export table to csv
write.csv(interest_table, "derivedData/interest_table.csv", row.names=TRUE)



```
	- subsetted visualisations of responses with separate subsetting by response to Q8-9, Q18, Q17, Q16
- For question Q8 + Q9 (for religious people) 
	- visualisation summary of responses
	- show subsetted visualisations of responses by response to, Q18, Q17, Q16, Q13, Q14
- For responses to Q10-12 (what subjects are involved in...):
	- represent answer counts as descending bar chart for each Q
	- subset answers by Q6 (positive / negative) and Q5 (positive / negative)

# Correlation testing:
- For Q6 (subject interest) / Q5 (subject knowledge) / Q7 employability prospects, test for nature / strength of correlation with responses to:
	- Q8-9 responses
	- Q18 responses
	- Q17


```{r Q6 Correlations - Subject Interest}
#Q8-9 (8 - Theology as subject for religious people; 9 - Religion as study for religious people)
  # This would be suitable for correlation

#Q17 (Ethnicity)
  # This would be categorical, so ANOVA

#Q18 (Religion)
  # This would also be categorical, so ANOVA

```

```{r Q5 Correlations - Subject Knowledge}
#Q8-9 (8 - Theology as subject for religious people; 9 - Religion as study for religious people)
  # This would be suitable for correlation

#Q17 (Ethnicity)
  # This would be categorical, so ANOVA

#Q18 (Religion)
  # This would also be categorical, so ANOVA
```

```{r Q7 Correlations - Employability}
#Q8-9 (8 - Theology as subject for religious people; 9 - Religion as study for religious people)
  # This would be suitable for correlation

#Q17 (Ethnicity)
  # This would be categorical, so ANOVA

#Q18 (Religion)
  # This would also be categorical, so ANOVA
```


```{r testing fun}
#testcor_data <- subject_data[subject_data$Subject == "Psychology" | subject_data$Subject == "Theology", ]

#t.test(Interest ~ Subject, data = testcor_data)

# testsubset <- TSR_data[TSR_data$Interested.in.Studying.Psychology < 3 & TSR_data$Interested.in.Studying.Psychology != 0, ]
# as.numeric(testsubset$Interested.in.studying.Theology)
# mean(testsubset$Interested.in.studying.Theology, na.rm = TRUE)
# 
# mean(as.numeric(testsubset$Interested.in.studying.Theology), na.rm = TRUE)
# 
# as.numeric(testsubset$Interested.in.studying.Religious.Studies)
# mean(testsubset$Interested.in.studying.Religious.Studies, na.rm = TRUE)
# 
# testsubset2 <- TSR_data[TSR_data$Interested.in.Studying.Psychology > 3, ]
# mean(as.numeric(testsubset2$Interested.in.studying.Theology), na.rm = TRUE)
# mean(as.numeric(testsubset2$Interested.in.studying.Religious.Studies), na.rm = TRUE)
```

## Mean Interest in Theology and Religious Studies by High/Low Subject Interest

```{r Philosophy}
# Base mean:

mean(as.numeric(TSR_data$InterestedinstudyingTheology), na.rm = TRUE)
mean(as.numeric(TSR_data$InterestedinstudyingReligiousStudies), na.rm = TRUE)
mean(as.numeric(TSR_data$InterestinstudyingPhilosophy), na.rm = TRUE)
mean(as.numeric(TSR_data$InterestedinStudyingPsychology), na.rm = TRUE)

### Philosophy ###
Philos_subset_Low <- TSR_data[TSR_data$InterestinstudyingPhilosophy < 3 & TSR_data$InterestinstudyingPhilosophy != 0, ]

Philos_subset_High <- TSR_data[TSR_data$InterestinstudyingPhilosophy > 3, ]

## Theology Interest
#Low interest in Philosophy
mean(as.numeric(Philos_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Philosophy
mean(as.numeric(Philos_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in Philosophy
mean(as.numeric(Philos_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in Philosophy
mean(as.numeric(Philos_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r Sociology}
### Sociology ###
Soc_subset_Low <- TSR_data[TSR_data$InterestinstudyingSociaology < 3 & TSR_data$InterestinstudyingSociaology != 0, ]

Soc_subset_High <- TSR_data[TSR_data$InterestinstudyingSociaology > 3, ]

## Theology Interest
#Low interest in Sociology
mean(as.numeric(Soc_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Sociology
mean(as.numeric(Soc_subset_High$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)
```

```{r Psychology}
### Psychology ###
Psych_subset_Low <- TSR_data[TSR_data$InterestedinStudyingPsychology < 3 & TSR_data$InterestedinStudyingPsychology != 0, ]

Psych_subset_High <- TSR_data[TSR_data$InterestedinStudyingPsychology > 3, ]

## Theology Interest
#Low interest in Psychology
mean(as.numeric(Psych_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Psychology
mean(as.numeric(Psych_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in Psychology
mean(as.numeric(Psych_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in Psychology
mean(as.numeric(Psych_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r History}
### History ###
Hist_subset_Low <- TSR_data[TSR_data$InterestedinstudyingHistory < 3 & TSR_data$InterestedinstudyingHistory != 0, ]

Hist_subset_High <- TSR_data[TSR_data$InterestedinstudyingHistory > 3, ]

## Theology Interest
#Low interest in History
mean(as.numeric(Hist_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in History
mean(as.numeric(Hist_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in History
mean(as.numeric(Hist_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in History
mean(as.numeric(Hist_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r Ethics}
### Ethics ###
Ethics_subset_Low <- TSR_data[TSR_data$InterestedinstudyingEthics < 3 & TSR_data$InterestedinstudyingEthics != 0, ]

Ethics_subset_High <- TSR_data[TSR_data$InterestedinstudyingEthics > 3, ]

## Theology Interest
#Low interest in Ethics
mean(as.numeric(Ethics_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Ethics
mean(as.numeric(Ethics_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in Ethics
mean(as.numeric(Ethics_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in Ethics
mean(as.numeric(Ethics_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r Politics}
### Politics ###
Polit_subset_Low <- TSR_data[TSR_data$InterestedinstudyingPolitics < 3 & TSR_data$InterestedinstudyingPolitics != 0, ]

Polit_subset_High <- TSR_data[TSR_data$InterestedinstudyingPolitics > 3, ]

## Theology Interest
#Low interest in Politics
mean(as.numeric(Polit_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Politics
mean(as.numeric(Polit_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in Politics
mean(as.numeric(Polit_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in Politics
mean(as.numeric(Polit_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r English}
### English ###
Eng_subset_Low <- TSR_data[TSR_data$InterestedinstudyingEnglish < 3 & TSR_data$InterestedinstudyingEnglish != 0, ]

Eng_subset_High <- TSR_data[TSR_data$InterestedinstudyingEnglish > 3, ]

## Theology Interest
#Low interest in English
mean(as.numeric(Eng_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in English
mean(as.numeric(Eng_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in English
mean(as.numeric(Eng_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in English
mean(as.numeric(Eng_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r Math}
### Math ###
Math_subset_Low <- TSR_data[TSR_data$InterestedinstudyingMath < 3 & TSR_data$InterestedinstudyingMath != 0, ]

Math_subset_High <- TSR_data[TSR_data$InterestedinstudyingMath > 3, ]

## Theology Interest
#Low interest in Math
mean(as.numeric(Math_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Math
mean(as.numeric(Math_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in Math
mean(as.numeric(Math_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in Math
mean(as.numeric(Math_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r Computer Science}
### Computer Science ###
CompSci_subset_Low <- TSR_data[TSR_data$InterestedinstudyingComputerScience < 3 & TSR_data$InterestedinstudyingComputerScience != 0, ]

CompSci_subset_High <- TSR_data[TSR_data$InterestedinstudyingComputerScience > 3, ]

## Theology Interest
#Low interest in Computer Science
mean(as.numeric(CompSci_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Computer Science
mean(as.numeric(CompSci_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in Computer Science
mean(as.numeric(CompSci_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in Computer Science
mean(as.numeric(CompSci_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)
```

```{r Business}
### Business ###
Busi_subset_Low <- TSR_data[TSR_data$InterestedinstudyingBusiness < 3 & TSR_data$InterestedinstudyingBusiness != 0, ]

Busi_subset_High <- TSR_data[TSR_data$InterestedinstudyingBusiness > 3, ]

## Theology Interest
#Low interest in Business
mean(as.numeric(Busi_subset_Low$InterestedinstudyingTheology), na.rm = TRUE)
#High interest in Business
mean(as.numeric(Busi_subset_High$InterestedinstudyingTheology), na.rm = TRUE)

## Religious Studies Interest
#Low interest in Business
mean(as.numeric(Busi_subset_Low$InterestedinstudyingReligiousStudies), na.rm = TRUE)
#High interest in Business
mean(as.numeric(Busi_subset_High$InterestedinstudyingReligiousStudies), na.rm = TRUE)

```


## Mean Knowledge in Theology and Religious Studies by High/Low Subject Knowledge

```{r Philosophy}
# Base calculations

mean(as.numeric(TSR_data$GoodunderstandingofTheology), na.rm = TRUE)
mean(as.numeric(TSR_data$GoodunderstandingofReligiousStudies), na.rm = TRUE)
mean(as.numeric(TSR_data$GoodunderstandingofPhilosophy), na.rm = TRUE)
mean(as.numeric(TSR_data$GoodunderstandingofPsychology), na.rm = TRUE)
mean(as.numeric(TSR_data$GoodunderstandingofEnglish), na.rm = TRUE)
mean(as.numeric(TSR_data$GoodunderstandingofMath), na.rm = TRUE)

### Philosophy ###

# Low understanding of philosophy cohort
Philos_subset_Low <- TSR_data[TSR_data$GoodunderstandingofPhilosophy < 3 & TSR_data$GoodunderstandingofPhilosophy != 0, ]

# High understanding of philosophy cohort
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_High$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)
```

```{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_High$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)
```

```{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_High$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)
```

```{r History}
### History ###
Hist_subset_Low <- TSR_data[TSR_data$GoodunderstandingofHistory < 3 & TSR_data$GoodunderstandingofHistory != 0, ]

Hist_subset_High <- TSR_data[TSR_data$GoodunderstandingofHistory > 3, ]

## Theology knowledge
#Low knowledge in History
mean(as.numeric(Hist_subset_Low$GoodunderstandingofTheology), na.rm = TRUE)
#High knowledge in History
mean(as.numeric(Hist_subset_High$GoodunderstandingofTheology), na.rm = TRUE)

## Religious Studies knowledge
#Low knowledge in History
mean(as.numeric(Hist_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE)
#High knowledge in History
mean(as.numeric(Hist_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE)
```

```{r Ethics}
### Ethics ###
Ethics_subset_Low <- TSR_data[TSR_data$GoodunderstandingofEthics < 3 & TSR_data$GoodunderstandingofEthics != 0, ]

Ethics_subset_High <- TSR_data[TSR_data$GoodunderstandingofEthics > 3, ]

## Theology knowledge
#Low knowledge in Ethics
mean(as.numeric(Ethics_subset_Low$GoodunderstandingofTheology), na.rm = TRUE)
#High knowledge in Ethics
mean(as.numeric(Ethics_subset_High$GoodunderstandingofTheology), na.rm = TRUE)

## Religious Studies knowledge
#Low knowledge in Ethics
mean(as.numeric(Ethics_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE)
#High knowledge in Ethics
mean(as.numeric(Ethics_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE)
```

```{r Politics}
### Politics ###
Polit_subset_Low <- TSR_data[TSR_data$GoodunderstandingofPolitics < 3 & TSR_data$GoodunderstandingofPolitics != 0, ]

Polit_subset_High <- TSR_data[TSR_data$GoodunderstandingofPolitics > 3, ]

## Theology knowledge
#Low knowledge in Politics
mean(as.numeric(Polit_subset_Low$GoodunderstandingofTheology), na.rm = TRUE)
#High knowledge in Politics
mean(as.numeric(Polit_subset_High$GoodunderstandingofTheology), na.rm = TRUE)

## Religious Studies knowledge
#Low knowledge in Politics
mean(as.numeric(Polit_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE)
#High knowledge in Politics
mean(as.numeric(Polit_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE)
```

```{r English}
### English ###
Eng_subset_Low <- TSR_data[TSR_data$GoodunderstandingofEnglish < 3 & TSR_data$GoodunderstandingofEnglish != 0, ]

Eng_subset_High <- TSR_data[TSR_data$GoodunderstandingofEnglish > 3, ]

## Theology knowledge
#Low knowledge in English
mean(as.numeric(Eng_subset_Low$GoodunderstandingofTheology), na.rm = TRUE)
#High knowledge in English
mean(as.numeric(Eng_subset_High$GoodunderstandingofTheology), na.rm = TRUE)

## Religious Studies knowledge
#Low knowledge in English
mean(as.numeric(Eng_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE)
#High knowledge in English
mean(as.numeric(Eng_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE)
```

```{r Math}
### Math ###
Math_subset_Low <- TSR_data[TSR_data$GoodunderstandingofMath < 3 & TSR_data$GoodunderstandingofMath != 0, ]

Math_subset_High <- TSR_data[TSR_data$GoodunderstandingofMath > 3, ]

## Theology knowledge
#Low knowledge in Math
mean(as.numeric(Math_subset_Low$GoodunderstandingofTheology), na.rm = TRUE)
#High knowledge in Math
mean(as.numeric(Math_subset_High$GoodunderstandingofTheology), na.rm = TRUE)

## Religious Studies knowledge
#Low knowledge in Math
mean(as.numeric(Math_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE)
#High knowledge in Math
mean(as.numeric(Math_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE)
```

```{r Computer Science}
### Computer Science ###
CompSci_subset_Low <- TSR_data[TSR_data$GoodunderstandingofComputerScience < 3 & TSR_data$GoodunderstandingofComputerScience != 0, ]

CompSci_subset_High <- TSR_data[TSR_data$GoodunderstandingofComputerScience > 3, ]

## Theology knowledge
#Low knowledge in Computer Science
mean(as.numeric(CompSci_subset_Low$GoodunderstandingofTheology), na.rm = TRUE)
#High knowledge in Computer Science
mean(as.numeric(CompSci_subset_High$GoodunderstandingofTheology), na.rm = TRUE)

## Religious Studies knowledge
#Low knowledge in Computer Science
mean(as.numeric(CompSci_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE)
#High knowledge in Computer Science
mean(as.numeric(CompSci_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE)
```

```{r Business}
### Business ###
Busi_subset_Low <- TSR_data[TSR_data$GoodunderstandingofBusiness < 3 & TSR_data$GoodunderstandingofBusiness != 0, ]

Busi_subset_High <- TSR_data[TSR_data$GoodunderstandingofBusiness > 3, ]

## Theology knowledge
#Low knowledge in Business
mean(as.numeric(Busi_subset_Low$GoodunderstandingofTheology), na.rm = TRUE)
#High knowledge in Business
mean(as.numeric(Busi_subset_High$GoodunderstandingofTheology), na.rm = TRUE)

## Religious Studies knowledge
#Low knowledge in Business
mean(as.numeric(Busi_subset_Low$GoodunderstandingofReligiousStudies), na.rm = TRUE)
#High knowledge in Business
mean(as.numeric(Busi_subset_High$GoodunderstandingofReligiousStudies), na.rm = TRUE)

```


## Mean Employability in Theology and Religious Studies by High/Low Subject Employability

```{r Philosophy}
# Base Calculations

mean(as.numeric(TSR_data$Theologyemployability), na.rm = TRUE)
mean(as.numeric(TSR_data$ReligiousStudiesemployability), na.rm = TRUE)
mean(as.numeric(TSR_data$Philosophyemployability), na.rm = TRUE)
mean(as.numeric(TSR_data$PsychologyEmployability), na.rm = TRUE)
mean(as.numeric(TSR_data$Englishemployability), na.rm = TRUE)
mean(as.numeric(TSR_data$Mathemployability), na.rm = TRUE)
mean(as.numeric(TSR_data$Businessemployability), na.rm = TRUE)
mean(as.numeric(TSR_data$ComputerScienceemployability), na.rm = TRUE)

### Philosophy ###
Philos_subset_Low <- TSR_data[TSR_data$Philosophyemployability < 3 & TSR_data$Philosophyemployability != 0, ]

Philos_subset_High <- TSR_data[TSR_data$Philosophyemployability > 3, ]

## Theology employability
#Low employability in Philosophy
mean(as.numeric(Philos_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Philosophy
mean(as.numeric(Philos_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Philosophy
mean(as.numeric(Philos_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Philosophy
mean(as.numeric(Philos_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r Sociology}
### Sociology ###
Soc_subset_Low <- TSR_data[TSR_data$Sociologyemployability < 3 & TSR_data$Sociologyemployability != 0, ]

Soc_subset_High <- TSR_data[TSR_data$Sociologyemployability > 3, ]

## Theology employability
#Low employability in Sociology
mean(as.numeric(Soc_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Sociology
mean(as.numeric(Soc_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Sociology
mean(as.numeric(Soc_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Sociology
mean(as.numeric(Soc_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r Psychology}
### Psychology ###
Psych_subset_Low <- TSR_data[TSR_data$PsychologyEmployability < 3 & TSR_data$PsychologyEmployability != 0, ]

Psych_subset_High <- TSR_data[TSR_data$PsychologyEmployability > 3, ]

## Theology employability
#Low employability in Psychology
mean(as.numeric(Psych_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Psychology
mean(as.numeric(Psych_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Psychology
mean(as.numeric(Psych_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Psychology
mean(as.numeric(Psych_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r History}
### History ###
Hist_subset_Low <- TSR_data[TSR_data$Historyemployability < 3 & TSR_data$Historyemployability != 0, ]

Hist_subset_High <- TSR_data[TSR_data$Historyemployability > 3, ]

## Theology employability
#Low employability in History
mean(as.numeric(Hist_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in History
mean(as.numeric(Hist_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in History
mean(as.numeric(Hist_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in History
mean(as.numeric(Hist_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r Ethics}
### Ethics ###
Ethics_subset_Low <- TSR_data[TSR_data$Ethicsemployability < 3 & TSR_data$Ethicsemployability != 0, ]

Ethics_subset_High <- TSR_data[TSR_data$Ethicsemployability > 3, ]

## Theology employability
#Low employability in Ethics
mean(as.numeric(Ethics_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Ethics
mean(as.numeric(Ethics_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Ethics
mean(as.numeric(Ethics_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Ethics
mean(as.numeric(Ethics_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r Politics}
### Politics ###
Polit_subset_Low <- TSR_data[TSR_data$Politicsemployability < 3 & TSR_data$Politicsemployability != 0, ]

Polit_subset_High <- TSR_data[TSR_data$Politicsemployability > 3, ]

## Theology employability
#Low employability in Politics
mean(as.numeric(Polit_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Politics
mean(as.numeric(Polit_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Politics
mean(as.numeric(Polit_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Politics
mean(as.numeric(Polit_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r English}
### English ###
Eng_subset_Low <- TSR_data[TSR_data$Englishemployability < 3 & TSR_data$Englishemployability != 0, ]

Eng_subset_High <- TSR_data[TSR_data$Englishemployability > 3, ]

## Theology employability
#Low employability in English
mean(as.numeric(Eng_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in English
mean(as.numeric(Eng_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in English
mean(as.numeric(Eng_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in English
mean(as.numeric(Eng_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r Math}
### Math ###
Math_subset_Low <- TSR_data[TSR_data$Mathemployability < 3 & TSR_data$Mathemployability != 0, ]

Math_subset_High <- TSR_data[TSR_data$Mathemployability > 3, ]

## Theology employability
#Low employability in Math
mean(as.numeric(Math_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Math
mean(as.numeric(Math_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Math
mean(as.numeric(Math_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Math
mean(as.numeric(Math_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r Computer Science}
### Computer Science ###
CompSci_subset_Low <- TSR_data[TSR_data$ComputerScienceemployability < 3 & TSR_data$ComputerScienceemployability != 0, ]

CompSci_subset_High <- TSR_data[TSR_data$ComputerScienceemployability > 3, ]

## Theology employability
#Low employability in Computer Science
mean(as.numeric(CompSci_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Computer Science
mean(as.numeric(CompSci_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Computer Science
mean(as.numeric(CompSci_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Computer Science
mean(as.numeric(CompSci_subset_High$ReligiousStudiesemployability), na.rm = TRUE)
```

```{r Business}
### Business ###
Busi_subset_Low <- TSR_data[TSR_data$Businessemployability < 3 & TSR_data$Businessemployability != 0, ]

Busi_subset_High <- TSR_data[TSR_data$Businessemployability > 3, ]

## Theology employability
#Low employability in Business
mean(as.numeric(Busi_subset_Low$Theologyemployability), na.rm = TRUE)
#High employability in Business
mean(as.numeric(Busi_subset_High$Theologyemployability), na.rm = TRUE)

## Religious Studies employability
#Low employability in Business
mean(as.numeric(Busi_subset_Low$ReligiousStudiesemployability), na.rm = TRUE)
#High employability in Business
mean(as.numeric(Busi_subset_High$ReligiousStudiesemployability), na.rm = TRUE)

```
