[R] calculate slope of line

2010-07-23 Thread Katrin Fleischer

Dear All,

I fear that this is a really easy question but I do seem to go around in 
circles..
I have 2 points on a plot and would like to calculate the slope of the 
line drawn through these 2 points.


that cant be so hard?!

Thank you in advance,
Katrin

--
Katrin Fleischer
Vrije Universiteit Amsterdam
Faculty of Earth and Life Sciences
Subdepartment Hydrolgy and Geo-Environmental Sciences
Room E-360
De Boelelaan 1085
1081 HV AMSTERDAM
Tel: +31 20 59 87391

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] calculate slope of line

2010-07-23 Thread Ted Harding
On 23-Jul-10 09:46:28, Katrin Fleischer wrote:
 Dear All,
 I fear that this is a really easy question but I do seem to go
 around in circles..
 I have 2 points on a plot and would like to calculate the slope
 of the line drawn through these 2 points.
 
 that cant be so hard?!
 
 Thank you in advance,
 Katrin

  (y2 - y1)/(x2-x1)

or, if X=c(x1,x2) and Y=c(y1,y2),

  diff(Y)/diff(X)

either of which is shorter than

  lm(Y ~ X)$coeff[2]  ##  !! :)

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 23-Jul-10   Time: 12:10:24
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.