top of page

9. Correlation analysis in R using the 'grow' dataframe from the growth dataset


Imperial Hairstreak

Correlation

You use correlation analysis to see if there is a significant relationship between two continuous variables.

For example (using the “grow” dataframe from the Regression example in the previous post) you might want to see if hatch weight and growth rate are related to one another, but that you hold no a priori ideas about which of the two variables drives the expression of the other.

To do a correlation in R you use the function “cor-test” as follows:

relationship<-cor.test(grow$growth, grow$weight)

To get the results of the correlation test, you just type the name you gave your correlation object (“relationship”) into the console.

relationship

Pearson's product-moment correlation

data: grow$growth and grow$weight

t = -0.40953, df = 22, p-value = 0.6861

alternative hypothesis: true correlation is not equal to 0

95 percent confidence interval:

-0.4737554 0.3279209

sample estimates:

cor

-0.08698194

The results are non-significant and you have to support your null hypothesis that the “true correlation is equal to 0”.

You report the results as follows, “correlation analysis showed hatch weight was not statistically related to growth rate (Pearson product-moment correlation coefficient = -0.09, t= -0.41, df = 22, P = 0.69).


bottom of page