-2

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 ?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
phpdash
  • 405
  • 3
  • 6
  • 7

2 Answers2

5

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.

Andrew Redd
  • 4,632
  • 8
  • 40
  • 64
1

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.

user1172558
  • 655
  • 4
  • 12
  • 18