For a linear model with 2 variables
r = lm(y ~ x1+x2)
When I run plot(r)
, I get a bunch of plots such as residuals vs fitted values and so on , but I can only look at one of them at a time .
Isn't there a way to separate them ?
For a linear model with 2 variables
r = lm(y ~ x1+x2)
When I run plot(r)
, I get a bunch of plots such as residuals vs fitted values and so on , but I can only look at one of them at a time .
Isn't there a way to separate them ?
A few ways. The most convenient is layout. ?layout
for more details
r<-lm(y~x1+x2)
layout(matrix(1:4,2,2))
plot(r)
will produce a window with four plots.
You could use the line:
par(mfrow=c(2,2))
before
plot(r)
In that way you say to R to show 4 pictures at the same frame. You can also set 4,1 to have 4 graphs one above the other, or 1,4 to have 4 graphs one on the side of the other.