[R] add a linear regression line to the plot

2011-01-13 Thread wangxipei
Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p) lines(lm(x~y),col=red,lwd=1.5) I got only plot without linear line. Many thanks ahead for your

[R] add a linear regression line to the plot

2011-01-13 Thread wo
Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p) lines(lm(x~y),col=red,lwd=1.5) I got only plot without linear line. Many thanks ahead for your

Re: [R] add a linear regression line to the plot

2011-01-13 Thread ONKELINX, Thierry
-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens wangxipei Verzonden: donderdag 13 januari 2011 9:35 Aan: r-help Onderwerp: [R] add a linear regression line to the plot Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression

Re: [R] add a linear regression line to the plot

2011-01-13 Thread Patrick Connolly
On Thu, 13-Jan-2011 at 04:35PM +0800, wangxipei wrote: | | Dear R users, |I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: | | x-c(10,20,40,80) | y-c(30,40,100,200) | plot(x,y,type=p) |

Re: [R] add a linear regression line to the plot

2011-01-13 Thread Dennis Murphy
?abline On Thu, Jan 13, 2011 at 12:29 AM, wo bellew...@163.com wrote: Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80) y-c(30,40,100,200) plot(x,y,type=p)

Re: [R] add a linear regression line to the plot

2011-01-13 Thread Eik Vettorazzi
Hi, lines(lm(x~y),col=red,lwd=1.5) should be abline(lm(y~x),col=red,lwd=1.5) hth. Am 13.01.2011 09:35, schrieb wangxipei: Dear R users, I am a new R user. My problem is very simple: I want to add a linear regression line to the plot(type=p), codes are as below: x-c(10,20,40,80)

Re: [R] add a linear regression line to the plot

2011-01-13 Thread ep
Hi, if it should be lines so you can do that xy.lm - lm(y~x) lines(x, xy.lm$coeff[1] + x*xy.lm$coeff[2], col=blue, lwd=3) Regards ep -- View this message in context: http://r.789695.n4.nabble.com/add-a-linear-regression-line-to-the-plot-tp3215455p3216099.html Sent from the R help mailing