Dear HelpeRs,
Given:
x - rnorm(50)
y - rnorm(50)
plot(x,y)
abline(lm(x ~ y))
Is there a way to plot just a portion of the line? Say for values of x
2.0 or x -2.0 and x 4.0. (Still fitting all the points.)
Thank you,
jab
--
John Bollinger, CFA, CMT
www.BollingerBands.com
If you advance
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: BBands [EMAIL PROTECTED]
To: R-Help r-help@stat.math.ethz.ch
Sent: Tuesday, January 16, 2007 5:16 PM
Subject: [R] plot
Use segments. In the following we overlay the black abline with
a wider red segments line segment:
set.seed(1)
x - rnorm(50)
y - rnorm(50)
plot(y ~ x)
y.lm - lm(y ~ x)
abline(y.lm) # omit this line if black abline not wanted
x0 - c(-2, 4)
y0 - predict(y.lm, list(x = x0))
segments(x0[1],
As in Dmitris' post lines is a somewhat more succint so here it is
again replacing segments with lines:
set.seed(1)
x - rnorm(50)
y - rnorm(50)
plot(y ~ x)
y.lm - lm(y ~ x)
abline(y.lm) # omit this line if black abline not wanted
x0 - c(-2, 4)
y0 - predict(y.lm, list(x = x0))
lines(y0 ~
Healthcare
[EMAIL PROTECTED]
(801) 408-8111
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of BBands
Sent: Tuesday, January 16, 2007 9:16 AM
To: R-Help
Subject: [R] plot portion of a line
Dear HelpeRs,
Given:
x - rnorm(50)
y - rnorm(50