Skip to content

Find the function of a line

3 messages · Ida Dolciotti, Sarah Goslee, PIKAL Petr

#
Hello everybody,

I have drawn a line in a x y plot  that links the minimum and maximum 
points in the plot

plot(xx,yy)

a=max(yy)
b=min(yy)

lines(c(xx[yy==a],xx[yy==b]),c(a,b))

Now I would like to know if it is possible to extrapolate the 
characteristic of the line (intercept and slope).

Is it there and appropriate function for this?

Thanks for your help!

Ida D.
#
lm()?
Or simple geometry?

lm(c(a,b) ~ c(xx[yy==a],xx[yy==b]))

will give you the slope and the intercept.

Sarah
On Wed, Jun 29, 2011 at 5:38 AM, Ida Dolciotti <ida.dolciotti at ufz.de> wrote:

  
    
#
Hi

r-help-bounces at r-project.org napsal dne 29.06.2011 11:38:17:
Maybe ?abline

Regards
Petr
http://www.R-project.org/posting-guide.html