data(tips)
x <- lm(tip ~ total_bill, data = tips)
tips.reg <- data.frame(tips, .resid = residuals(x), .fitted = fitted(x))
library(ggplot2)
ggplot(lineup(null_lm(tip ~ total_bill, method = 'rotate'), tips.reg)) +
geom_point(aes(x = total_bill, y = .resid)) +
facet_wrap(~ .sample)
Run the code above in your browser using DataLab