[R] Slope between two points

2009-10-08 Thread FMH
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

Re: [R] Slope between two points

2009-10-08 Thread baptiste auguie
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 kagba2...@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)