-1

enter image description here enter image description here

Kindly request to refer to the images to get a complete understanding

I have a huge dataset with numeric values. I would need to find the points at which an increasing or decreasing trend starts and ends.

E.g: [100312 100317 100380 100432 100438 100441 100509 100641 100779 100919 100983 100980 100978 100983 100986 100885 100767 100758 100755 100755]

I have shown 5000 of the 1 million rows I have in my data.

Output > 100317(starting point of increase),100432 (end point of increase), 100441 (starting point of increase) 100919(end point of increase).

A change of ~10 is considered as noise.

  • You should improve your original question based on others' suggestion, not start a new post. – www Sep 04 '17 at 03:42
  • And even in this new post, I do not see any significant improvement. Please see this post to learn how to make a good reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – www Sep 04 '17 at 03:44
  • @ycw: Apologies. My second question on SO after the one I posted earlier today. Will definitely update the question with a reproducible example. – veggie crunch burger Sep 04 '17 at 03:51

1 Answers1

0

you can try this code; starting point of increase and ending point of increase

df <- c(100312,100317,100380,100432,100438,100441,100509,100641,100779,100919,100983,100980,100978,100989,100999,100885,100767,100758,100755,100755)
indexs <- which(diff(df) >= 10)
flag <- which(diff(indexs) > 1)
end <- c(flag, length(indexs))
start <- c(1, end[-length(end)] + 1)
mapply(function(x, y) c(df[indexs[x]], df[indexs[y]]), start, end)
myincas
  • 1,500
  • 10
  • 15