mydata <- read.csv("study3data.cleaned.v3.csv")

jmv::descriptives(mydata, vars = vars(asi, perf.cog, perf.sop, perf.swc, perf.com, perf.daa, perf.selfc, perf.self, ac.se, ganx), missing = TRUE)
jmv::descriptives(mydata, vars = vars(fof,sars,achstriv, comp,flow,swl,ewb), missing = TRUE)
#looking at correlations of numeric variables 
plot<- mydata[,c("age", "school", "asi", "perf.sop", "perf.swc", "perf.com", "perf.daa", "perf.cog", 
                 "perf.self", "ganx", "fof", "sars", "achstriv",
                                    "comp", "flow", "swl", "ewb")]

#Calculating correlations and CIs
cor1 <- cor.mtest(plot, use="pairwise.complete.obs", conf.level = 0.95)

#Labels for the subsequent plot
cor1b <- cor(plot, use="pairwise.complete.obs")

rownames(cor1b) <- c("Age",
                     "Dalhousie",
                                         "Anxiety sensitivity",
                                         "Self-oriented perfectionism",
                                         "Self-worth contingencies",
                                         "Concern over mistakes",
                                         "Doubts about actions",
                                         "Perfectionistic cognitions",
                                         "Perfectionistic self-presentation",
                                         "General anxiety",
                                         "Fear of failure",
                                         "Statistics anxiety",
                                         "Achievement striving",
                                         "Competence",
                                         "Flow",
                                         "Life satisfaction",
                                         "Eudaimonic well-being")


colnames(cor1b) <- c("Age",
                     "Dalhousie",
                     "Anxiety sensitivity",
                     "Self-oriented perfectionism",
                     "Self-worth contingencies",
                     "Concern over mistakes",
                     "Doubts about actions",
                     "Perfectionistic cognitions",
                     "Perfectionistic self-presentation",
                                         "General anxiety",
                                         "Fear of failure",
                                         "Statistics anxiety",
                                         "Achievement striving",
                                         "Competence",
                                         "Flow",
                                         "Life satisfaction",
                                         "Eudaimonic well-being")


#Correlation Matrix

corrplot(cor1b, method="color", type="upper",
         addCoef.col = "black", tl.col="black", tl.srt=40, p.mat = cor1$p, tl.cex = .6,
         sig.level = 0.05, insig = "n", diag=FALSE, number.cex = 0.7,
                 col=colorRampPalette(c("#94AEBC", "#F5EABF", "#728393"))(50))