TFB
TFB

Reputation: 13

combining two regression lines drawn from different datasets

I have a 2 different datasets. I plotted two of their regreesion lines. I need to show these two in the same regression plot. How can I do?

reg1 <- lm(a~b,data1) reg2 <-lm(a~b,data2)

Thanks

Upvotes: 0

Views: 432

Answers (1)

mischva11
mischva11

Reputation: 2956

You can create an "empty" plot with type="n" and then add your regression lines with abline

df <- mtcars

reg1 <- lm(mpg~cyl,mtcars)
reg2 <-lm(disp~hp,mtcars)
plot(c(0,0),c(0,60),type="n")        
abline(reg1)
abline(reg2)

you also can add points with points if you want. Then you also don't need to make the empty plot before, since it's "normal" plotting and then just adding ablines.

Upvotes: 1

Related Questions