You can use the clipplot function in the TeachingDemos package to limit the
range of the line (the 2nd example in the help page shows an example of 3 lines
for 3 subgroups of data with each line limited to the x-range of the data).
There is also the clip function in the graphics package (no ext
On Wed, Jun 18, 2008 at 9:09 PM, Tariq Perwez <[EMAIL PROTECTED]> wrote:
> Hi
> I just realized that when I use linear regression to draw a line through my
> data points with something like the following:
>
> abline(lm(y ~ x))
>
>
> the length of the line is infinite, i.e., the line goes beyond the
On 19/06/2008, at 2:09 PM, Tariq Perwez wrote:
Hi
I just realized that when I use linear regression to draw a line
through my
data points with something like the following:
abline(lm(y ~ x))
the length of the line is infinite, i.e., the line goes beyond the
smallest
and the largest data
That's normally how its done so you might want to reconsider whether
you really want only the line segment; however, if you insist see ?segments
plot(y ~ x)
y.lm <- lm(y ~ x)
n <- length(x)
# x assumed to be in ascending or descending order
segments(x[1], fitted(y.lm)[1], x[n], fitted(y.lm)[n])
4 matches
Mail list logo