Ch 4: Scatterplots and Correlation
In a random sample of 8 college women, each was asked her height (inch) and her weight (pound).
|College women's heights and weights|
|Heights, x||Weights, y|
Draw a scatterplot.
> x <- c(65,65,62,67,69,65,61,67) > y <- c(105,125,110,120,140,135,95,130) > plot(x,y, col="red", pch=15) > plot(y~x, col="red", pch=15)
Two plot commands above will produce identical results. In the plot commands, col="red" defines the color of dots and pch=15 defines symbol. Consult this for a list of symbols. For a chart of color, look at this.
Pearson Correlation Coefficient, r
Linear correlation coefficient between x (height) and y (weight).
> cor(x,y)  0.7979212
> cor.test(x,y) Pearson's product-moment correlation data: x and y t = 3.2426, df = 6, p-value = 0.01763 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: 0.2130285 0.9617997 sample estimates: cor 0.7979212
[ Going back to Using R: Index ]