0

I have a numeric vector in R containing a large set of value (ex. 0.05, 0.06, 0.09 etc.). I would like to perform a mathematical operation by sequential +1 moving alongside the vector. For example, I want a mean of 5 points (from 1-5), then move one position and get the mean (positions 2-6) and repeat (positions 3-7, 4-8 and so on). Store the values in a vector and eventually plot.

MrFlick
  • 195,160
  • 17
  • 277
  • 295
ThePresident
  • 301
  • 6
  • 16
  • 1
    You are describing a "rolling mean". If you search for that term, you are likely to find many useful answers. – MrFlick Apr 10 '17 at 15:17
  • Thank you, I didn't really know what to search exactly. However, I'm not interested in a mean per se, but I guess the principle will be the same. Should I delete my question since it's a duplicate? – ThePresident Apr 10 '17 at 15:41

0 Answers0