title: R time series finding indices with sign change
body: <p>I have a time series as below. I simply want to find the indices where the observations at <code>t</code> and <code>t+1</code> have different signs.</p>
  
  <p>Obviously, I can achieve this by getting the indices where <code>t*(t-1)&lt;0</code>. However I am not sure about the best function to implement this logic.</p>
  
  <p>What is the fastest way to achieve this in <strong>base R</strong>? </p>
  
  <pre><code>b &lt;- structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.00117300000000009, 
              0.00165400000000004, 0.00262999999999991, 0.00236499999999995, 
              0.00571200000000016, 0.00364100000000001, 0.0013479999999999, 
              -0.0013510000000001, -0.00270499999999996, -0.00338699999999981, 
              -0.000166000000000111, -0.00105099999999991, -0.002467, -0.00367300000000004, 
              -0.00569500000000001, -0.00446499999999994, -0.002861, -0.00129699999999988, 
              0.000721000000000194, 0.00351799999999969, 0.0040929999999999, 
              0.00418700000000016, 0.004189, 0.00348199999999999, 0.0015729999999996, 
              5.89999999998092e-05, -0.000866000000000255, -0.00130799999999986, 
              0.00158199999999997, 0.00198000000000009, 0.00180899999999995, 
              0.000526999999999944, -0.000598000000000098, -0.00189899999999987, 
              -0.00285700000000011, -0.00296200000000013, -0.000966000000000244, 
              0.00388200000000016, 0.00311499999999998, 0.00300600000000006
  ), .Tsp = c(1, 49, 1), class = "ts")
  </code></pre>