[R] Finding points where two timeseries cross over

Matthew Dowle mdowle at mdowle.plus.com
Wed Aug 4 16:16:14 CEST 2010


Is this what you mean?

x=c(1,2,2,3,4,5,6,3,2,1)
y=c(2,3,4,2,1,2,3,4,5,6)
matplot(cbind(x,y),type="l")
which(diff(sign(x-y))!=0)+1
[1] 4 8

-- 
View this message in context: http://r.789695.n4.nabble.com/Finding-points-where-two-timeseries-cross-over-tp2313257p2313510.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list