# NOT RUN {
library(matrixStrucTest)
library(ggplot2)
data("big5")
# get column numbers for questionnaire items
items <- grep("[0-9]", colnames(big5))
# compute Spearman's correlation matrix
A <- cor(big5[, items], use = "complete.obs", method = "spearman")
groups <- "extrovert ~ E1 + E2 + E3 + E4 + E5 + E6 + E7 + E8 + E9 + E10
neurotic ~ N1 + N2 + N3 + N4 + N5 + N6 + N7 + N8 + N9 + N10
agreeable ~ A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9 + A10
conscientious ~ C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8 + C9 + C10
open ~ O1 + O2 + O3 + O4 + O5 + O6 + O7 + O8 + O9 + O10"
# Make box plots contrasting within and between group correlations
box <- prepBoxPlots(A = A, groups = groups, absolute = TRUE)
ggplot(aes(x = as.factor(delta), y = a), data = box$overall)+
geom_boxplot()+
theme_bw(22)+
labs(x = expression(Delta), y="|a|")
dev.new(width = 12, height = 5)
ggplot(aes(x = as.factor(delta), y = a), data = box$multi)+
geom_boxplot()+
facet_grid(~block)+
theme_bw(22)+
labs(x = expression(Delta), y = "|a|")
# }
Run the code above in your browser using DataLab