R - Correlation

> Procedural Languages > R

1 - About

3 - Package

3.1 - Stats

# Correlation analysis of baseline measures
 
# Matrix of correlation
round(cor(data), 2) # Round to 2 decimal places 
 
# One correlation
cor(data$variable1 , data$variable2)
 
# Pearson's product-moment correlation test hypothesis
cor.test(data$variable1 , data$variable2)
	Pearson's product-moment correlation

data:  data$variable1 , data$variable2
t = 4.9022, df = 198, p-value = 1.969e-06
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.1993491 0.4473145
sample estimates:
      cor 
0.3289909 

with:

Advertising