setwd("~/ACS/PracticeCode")
library(RColorBrewer)
education = read.table("education.txt", header = TRUE, row.names = 1)
head(education)
## sup.help sup.under sup.safe sup.conc adv.comp adv.acces adv.comm
## 1 7 1 7 4 5 5 6
## 2 7 1 6 4 6 6 5
## 3 6 1 6 6 6 6 6
## 4 1 7 3 1 1 2 1
## 5 6 5 5 7 7 6 7
## 6 6 1 6 5 7 7 7
## adv.qual tut.prof tut.sched tut.stud tut.qual val.devel val.deci
## 1 6 5 4 6 7 5 5
## 2 6 6 6 6 6 6 4
## 3 6 6 6 6 6 6 7
## 4 1 3 2 1 1 1 1
## 5 7 7 7 6 7 7 7
## 6 6 6 7 6 7 6 6
## val.meet val.info sat.glad sat.expe sat.over loy.proud loy.recom
## 1 6 7 7 7 7 7 7
## 2 7 6 7 7 7 7 7
## 3 7 7 7 6 6 7 7
## 4 1 2 1 1 1 1 1
## 5 7 7 7 7 7 7 7
## 6 6 6 7 6 7 7 7
## loy.asha loy.back gender scholarships job
## 1 1 7 female yes_scholship no_job
## 2 1 7 female yes_scholship yes_job
## 3 1 7 female yes_scholship no_job
## 4 7 1 male no_scholship no_job
## 5 1 7 female yes_scholship yes_job
## 6 1 7 female no_scholship no_job
aux_distrib = table(education[, 1])/nrow(education)
# barplot of the distribution
barplot(aux_distrib, border = NA, main = colnames(education)[1])

sq1 = "One"
sq2 = "Two"
sq3 = "Three"
sq4 = "Four"
sup_questions = c(sq1, sq2, sq3, sq4)
op = par(mfrow = c(2,2), mar = c(2.5, 3.2, 2, 0.8))
for (j in 1:4) {
distribution = table(education[,j]) / nrow(education)
barplot(distribution, border = NA, col = brewer.pal(8, "Blues")[2:8],
axes = FALSE, main = sup_questions[j], cex.main = 1)
# add vertical axis, and rectangle around figure
axis(side = 2, las=2)
box("figure", col="gray70")
}

par(op)