Dear Dimitris,

It works beautifully!

Many thanks

Rhelpers are great!

All the best,

Nguyen

try this:

x <- rnorm(200, 35, 5)
y <- rnorm(200, 0.87, 0.12)
###########
lmObj <- lm(y ~ x)
xs <- range(x)
ys <- predict(lmObj, newdata = data.frame(x = xs))
plot(x, y, pch = 17, bty = "l")
lines(xs, ys, col = "red", lty = 2, lwd = 2)

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
    http://www.student.kuleuven.be/~m0390867/dimitris.htm

----- Original Message -----
From: "Nguyen Dinh Nguyen" <n.nguyen@garvan.org.au>
To: <r-help@stat.math.ethz.ch>
Sent: Tuesday, March 20, 2007 12:32 PM
Subject: [R] abline within data range

> Dear R helpers,
>
> I would like to have abline,  for a lm model for
> example, lying within data range. Do you know how
to
> get it?
>
> Thank in advance
>
> Nguyen D Nguyen
>
> #CODE
> x<- rnorm(200, 35,5)
> y<- rnorm(200, 0.87,0.12)
> plot(y~x, xlim=c(0,50), pch=17, bty="l")
> abline(lm(y~x))
>
> # I would like abline is between min(x) and max(x)

 

	[[alternative HTML version deleted]]

