## Lab Exercise 3 for R: Analyzing associations

### Exercise 1: Scatterplots and more

If two independent samples are obtained, then we can ask whether they correlate to some extent. Correlation coefficients measure the strength of the linear relationship between these two variables

 Download and read the content from file "Golf.txt" which lists divorce rates and number of golf courses for 20 US cities. The obtain Pearson's Product Moment Correaltion Coefficient ...     > Golf <- read.table("http://caspar.bgsu.edu/~courses/stats/Labs/Datasets/Golf.txt", header=TRUE)     > cor(Golf\$GolfCourses,Golf\$DivorceRate); or simply obtain the correlation matrix for all variables contained in the dataframe, in this case using the method for rank correlations     > cor(Golf, method = "spearman") For a more comprehensive view of the associations between variables create a correlation matrix with library Deducer, then print the results ...     > library(Deducer)     > Golf.corrMat<-cor.matrix(variables=d(Golf\$GolfCourses,Golf\$DivorceRate), test=cor.test, method='pearson', alternative="two.sided")     > print(Golf.corrMat) Create scatterplot of the correaltion matrix with added linear model for fit ...     > qscatter_array(d(GolfCourses,DivorceRate),d(GolfCourses,DivorceRate),data=Golf) + geom_smooth(method="lm") or a sweet one with ggpairs from library GGally ...     > library(GGally)     > ggpairs(Golf)