[R] abline within data range

Greg Snow
Tue, 20 Mar 2007 17:43:37 -0000

One approach is to use the clipplot function from the TeachingDemos
package.  This is probably overkill to load the package for doing this
just once, but if you are creating a more complicated graph with several
lines limited by their range then this may be of interest.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111



> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Nguyen
> Dinh Nguyen
> Sent: Tuesday, March 20, 2007 5:32 AM
> To: r-help at stat.math.ethz.ch
> 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]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html