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)
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)
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)
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))
age_pie<-pie(table(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)
age_pie<-pie(table(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))
TSR_data<-read.csv("./data/TSR data complete.csv")
TSR_data_summaries$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"))
TSR_data_summaries<-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"))
# JK note: To keep things tidy, I've shifted the code here so that this isn't overwriting the dataset, but is instead operating off a separate df (same below)
TSR_data_summaries_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"))
# JK note: adding in a bar chart here, as according to the interwebs it's (apparently?) more accurate to visualise than bar charts
ggplot(TSR_data,aes(TSR_data_summaries_age))+geom_bar()+title("Age of respondents")
# JK note: To keep things tidy, I've shifted the code here so that this isn't overwriting the dataset, but is instead operating off a separate df (same below)
TSR_data_summaries_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"))
data_summaries_age+labs(title="Respondent Age Distribution",x="Age")
data_summaries_age+labs(title="Respondent Age Distribution",x="Age",y="")
# save to png file for reports
ggsave("figures/TSR_data_summaries_age.png")
TSR_data_summaries_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_summaries_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"))
data_summaries_yos<-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<-read.csv("./data/TSR data complete.csv")
data_summaries_yos<-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"))
Year_study_pie<-pie(table(data_summaries_yos))
pie(table(data_summaries_yos))
TSR_data_summaries_yos<-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$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<-read.csv("./data/TSR data complete.csv")
View(TSR_data)
View(TSR_data)
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_age+labs(title="Respondent Age Distribution",x="Age",y="")
# save to png file for reports
ggsave("figures/TSR_data_summaries_age.png")
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"))
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"))
library("stringr")# Load stringr package, used for wrapping label text in plots
# 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")
# JK note: To keep things tidy, I've shifted the code here so that this isn't overwriting the dataset, but is instead operating off a separate df (same below)
TSR_data_summaries_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"))
# JK note: adding in a bar chart here, as according to the interwebs it's (apparently?) more accurate to visualise than bar charts
data_summaries_age+labs(title="Respondent Age Distribution",x="Age",y="")
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+labs(title="Respondent Most Recent Year of Study",x="",y="")
# save to png file for reports
ggsave("figures/TSR_data_summaries_yos.png")
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"))
TSR_data_summaries_ethnicity$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","Asian/Asian British - Indian","Asian/Asian British - Pakistani","Asian/Asian British - Bangladeshi","Asian/Asian British - Chinese","Asian/Asian British - Any other Asian background","Black/Black British - African","Black/Black British - Caribbean","Black/Black British - Any other Black background","Mixed/Multiple Ethnic Groups - White and Black Caribbean","Mixed/Multiple Ethnic Groups - White and Black African","Mixed/Multiple Ethnic Groups - White and Black Asian","Mixed/Multiple Ethnic Groups - Any other Mixed/Multiple Ethnic background","White - English/Welsh/Scottish/Northern Irish/British","White - Irish","White - Gypsy or Irish Traveller","White - Any other White background","Other Ethnic group, please describe","Prefer not to say"))
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","Asian/Asian British - Indian","Asian/Asian British - Pakistani","Asian/Asian British - Bangladeshi","Asian/Asian British - Chinese","Asian/Asian British - Any other Asian background","Black/Black British - African","Black/Black British - Caribbean","Black/Black British - Any other Black background","Mixed/Multiple Ethnic Groups - White and Black Caribbean","Mixed/Multiple Ethnic Groups - White and Black African","Mixed/Multiple Ethnic Groups - White and Black Asian","Mixed/Multiple Ethnic Groups - Any other Mixed/Multiple Ethnic background","White - English/Welsh/Scottish/Northern Irish/British","White - Irish","White - Gypsy or Irish Traveller","White - Any other White background","Other Ethnic group, please describe","Prefer not to say"))
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","African","Caribbean","Any other Black background","White and Black Caribbean","White and Black African","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<-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_religion<-factor(TSR_data$Religious.Affliation,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_summaries_religion<-factor(TSR_data$Religious.Affliation,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_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"))
employability_bar+labs(title="please rate from 1 to 5 where 1 represents 'Good employability prospects’ and 5 represents ‘Poor employability prospects'",x="",y="")
library("stringr")# Load stringr package, used for wrapping label text in plots
library(dplyr)# Used for filtering below
# 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:
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_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_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_positive_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_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"))