title: R: Err: only 0's may be mixed with negative subscripts
body: <p>Apparently I am trying to subset my variable with positive and "negative indexes". However debugging the code, I can not why R studio is interpreting it as I am mixing negative and positive subsets. </p>
  
  <p>Here is the part of the code:</p>
  
  <pre><code> if (stepcount &gt; 192 | sum(na.omit(ppt[i-193:i-1])) &lt; 0.6) {statement}
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Error in ppt[i - 193:i - 1] : 
    only 0's may be mixed with negative subscripts
  </code></pre>
  
  <p>Debugging the code I see that my value for i at this point is 3572 which means nor negative subsetting in <code>ppt[i - 193:i - 1]</code></p>
  
  <p>If it helps, just some more information: if I use two "or" operator instead of one, like:</p>
  
  <pre><code>if (stepcount &gt; 192 || sum(na.omit(ppt[i-193:i-1])) &lt; 0.6) {statement}
  </code></pre>
  
  <p>I still get the same err but in i being 3603. Honestly I don't know the difference but may be it conveys some kind of information that could clarify the problem. </p>
  
  <p>I think that this is probably a simple thing that I am not aware of and that the reproducible code would not be necessary (since it is a too long code to analyse a large data. However I could post it on, if you guys think that is necessary. </p>