Hi,
Like this perhaps?
> slope = diff(y) / diff(x)
> str(slope)
num [1:499] 1.5068 -1.8406 2.1745 0.0676 -2.6088 ...
HTH,
baptiste
2009/10/8 FMH <kagba2006 at yahoo.com>:> 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
> Fir
>
>
>
> ______________________________________________
> R-help at 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.
>