# # 20100827.R # # Bivariate analysis # Read in the data data <- read.csv("data1-3a.csv") attach(data) # See the data data # A feel for the data (univariate) mean(x) median(x) sd(x) IQR(x) boxplot(x) mean(y) median(y) sd(y) IQR(y) boxplot(y) # Of x and y together, individually boxplot(x,y, notch=TRUE, names=c("x","y")) # Of x and y together, showing a relationship: a scatterplot plot(x,y) # A better scatterplot: plot(x,y, xlim=c(0,600), ylim=c(-1000, 2000), xlab="x-value", ylab="y-value", main="Scatterplot of y against x", pch=16, col="blue", lwd=2, las=1) # What is that line of best fit? model1 <- lm(y~x) abline(model1$coef[[1]],model1$coef[[2]], col="red", lwd=2) # # This linear model (lm) will be explained in the future. No worries.