set.seed(1234)
X <- rnorm (480, 10,5)
myd <- data.frame (X1 = rep (c("A", "B", "C", "D"), each = 120), X2 = rep (rep(rep(c("E", "F"), 4), each = 30), 4), X3 = X, Y = X*0.5 + rnorm (length (X), 0, 4))
# need ggplot2
library(ggplot2)
qplot(X3, Y, data=myd, facets=X1~X2, xlab="X1 (units)", ylab="Y1 (units)") + theme_bw()
# add regression lines
qplot(X3, Y, data=myd, facets=X1~X2, xlab="X1 (units)", ylab="Y1 (units)", geom=c("point", "smooth"), method="lm", formula= y~x) + theme_bw()
X <- rnorm (480, 10,5)
myd <- data.frame (X1 = rep (c("A", "B", "C", "D"), each = 120), X2 = rep (rep(rep(c("E", "F"), 4), each = 30), 4), X3 = X, Y = X*0.5 + rnorm (length (X), 0, 4))
# need ggplot2
library(ggplot2)
qplot(X3, Y, data=myd, facets=X1~X2, xlab="X1 (units)", ylab="Y1 (units)") + theme_bw()
# add regression lines
qplot(X3, Y, data=myd, facets=X1~X2, xlab="X1 (units)", ylab="Y1 (units)", geom=c("point", "smooth"), method="lm", formula= y~x) + theme_bw()
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.