Skip to content

Instantly share code, notes, and snippets.

Created August 15, 2014 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6b7b201de86ed83f1258 to your computer and use it in GitHub Desktop.
Save anonymous/6b7b201de86ed83f1258 to your computer and use it in GitHub Desktop.
data <- read.table("./AnscombeQuartet.csv", header = TRUE, sep =",", dec = ".", colClasses = c("numeric"))
mean(data$x1)
var(data$x1)
sapply(data, mean)
sapply(data, var)
par(mfrow=c(2,2), mar=c(2.0, 1.5, 1.5, 1.5), oma = c(2,2,2,2), pch = 16)
for(i in 1:4){
x = eval(parse(text = paste("data$x",i,sep="")))
y = eval(parse(text = paste("data$y",i,sep="")))
plot( x, y )
abline( lm(y ~ x) )
grid( 10,10 )
}
### Plot figures one by one:
# par(mfrow=c(2,2), mar=c(2.0, 1.5, 1.5, 1.5), oma = c(2,2,2,2), pch = 16)
# plot(data$x1, data$y1, xlab = "x", ylab = "y"); grid(10,10)
# abline(lm(data$y1~data$x1))
#
# plot(data$x2, data$y2, xlab = "x", ylab = "y"); grid(10,10)
# abline(lm(data$y2~data$x2))
#
# plot(data$x3, data$y3, xlab = "x", ylab = "y"); grid(10,10)
# abline(lm(data$y3~data$x3))
#
# plot(data$x4, data$y4, xlab = "x", ylab = "y"); grid(10,10)
# abline(lm(data$y4~data$x4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment