title: Finding local maxima and minima
body: <p>I'm looking for a computationally efficient way to find local maxima/minima for a large list of numbers in R.
  Hopefully without <code>for</code> loops...</p>
  
  <p>For example, if I have a datafile like <code>1 2 3 2 1 1 2 1</code>, I want the function to return 3 and 7, which are the positions of the local maxima.</p>