[R] Slope between two points

FMH kagba2006 at yahoo.com
Thu Oct 8 11:24:09 CEST 2009

Dear All,

Let  499 piece-wise lines were buit up by 500 pair of observations, via R code below.

x <- 1:500
y <- rnorm(500)
plot(x, y, type = 'b')

I was trying to compute all the slopes for the  lines which were connected between two adjacent points. For instance, slopes of lines between first and second points, second and third points, and so on, until between  points 499 and 500, respectively, but sadly, i never found a suitable function do this computatation efficiently.

Could someone please advice me on doing this?

Thank you


More information about the R-help mailing list