SOURCEBOOK

R | Data Analysis

Correlations

Prior to the steps below, enter the data as appropriate for the analyses (described elsewhere). As always, the following commands should be typed directly in the R console window.

Obtaining Descriptive Statistics

Get the means and standard deviations for the variables.

mean(Outcome1)
sd(Outcome1)
mean(Outcome2)
sd(Outcome2)

Get the covariance and correlation matrices for the variables.

cov(Outcome1,Outcome2)
cor(Outcome1,Outcome2)

Obtaining Inferential Statistics

Get the correlation, its test for statistical significance, and its confidence interval.

cor.test(Outcome1,Outcome2)