> d <- read.csv("personality.csv") > d[1:3,] id Completed age gender pers1 ocd1 pers2 ocd2 pers3 pers4 ocd3 ocd4 pers5 1 1 Y 20 M 2 3 3 1 4 2 3 2 4 2 2 Y 28 F 2 2 2 3 3 3 3 1 2 3 3 Y 24 F 1 2 2 2 3 2 4 1 1 ocd5 1 4 2 3 3 3 > d$pers <- d$pers1 + d$pers2 + d$pers3 + d$pers4 + d$pers5 > d[1:3,] id Completed age gender pers1 ocd1 pers2 ocd2 pers3 pers4 ocd3 ocd4 pers5 1 1 Y 20 M 2 3 3 1 4 2 3 2 4 2 2 Y 28 F 2 2 2 3 3 3 3 1 2 3 3 Y 24 F 1 2 2 2 3 2 4 1 1 ocd5 pers 1 4 15 2 3 12 3 3 9 > d$ocd <- d$ocd1 + d$ocd2 + d$ocd3 + d$ocd4 + d$ocd5 > d[1:3,] id Completed age gender pers1 ocd1 pers2 ocd2 pers3 pers4 ocd3 ocd4 pers5 1 1 Y 20 M 2 3 3 1 4 2 3 2 4 2 2 Y 28 F 2 2 2 3 3 3 3 1 2 3 3 Y 24 F 1 2 2 2 3 2 4 1 1 ocd5 pers ocd 1 4 15 13 2 3 12 12 3 3 9 12 > plot(d$pers, d$ocd) > cor.test(d$pers, d$ocd) Pearson's product-moment correlation data: d$pers and d$ocd t = 0.5949, df = 71, p-value = 0.5538 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.1622677 0.2957047 sample estimates: cor 0.07042888 > plot(d$age, d$pers) > cor.test(d$age, d$pers) Pearson's product-moment correlation data: d$age and d$pers t = 1.4475, df = 71, p-value = 0.1521 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.0632198 0.3844038 sample estimates: cor 0.1693101 > plot(d$age,d$ocd) > cor.test(d$age, d$ocd) Pearson's product-moment correlation data: d$age and d$ocd t = -2.3315, df = 71, p-value = 0.02257 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.46802640 -0.03899937 sample estimates: cor -0.2666739 > help(abline) > abline(lm(d$ocd~d$age)) > cor.test(d$pers, d$ocd) Pearson's product-moment correlation data: d$pers and d$ocd t = 0.5949, df = 71, p-value = 0.5538 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.1622677 0.2957047 sample estimates: cor 0.07042888 > plot(d$pers, d$ocd) > abline(lm(d$ocd~d$pers)) > d[1:3, ] id Completed age gender pers1 ocd1 pers2 ocd2 pers3 pers4 ocd3 ocd4 pers5 1 1 Y 20 M 2 3 3 1 4 2 3 2 4 2 2 Y 28 F 2 2 2 3 3 3 3 1 2 3 3 Y 24 F 1 2 2 2 3 2 4 1 1 ocd5 pers ocd 1 4 15 13 2 3 12 12 3 3 9 12 > mocd <- d$ocd[d$gender=="M"] > focd <- d$ocd[d$gender == "F"] > wilcox.test(mocd, focd, paired=F, exact=F) Wilcoxon rank sum test with continuity correction data: mocd and focd W = 521, p-value = 0.5209 alternative hypothesis: true location shift is not equal to 0 > mpers <- d$pers[d$gender=="M"] > fpers <- d$pers[d$gender=="F"] > wilcox.test(mpers, fpers, paired=F, exact=F) Wilcoxon rank sum test with continuity correction data: mpers and fpers W = 622.5, p-value = 0.5687 alternative hypothesis: true location shift is not equal to 0 > length(mpers); length(fpers) [1] 27 [1] 55 >