title: About missing value where TRUE/FALSE needed in R
body: <p>I want to return the number of times in string vector v that the element at the next successive index has more characters than the current index.
  Here's my code </p>
  
  <pre><code>BiggerPairs &lt;- function (v) {
  numberOfTimes &lt;- 0
  for (i in 1:length(v)) {
  if((nchar(v[i+1])) &gt; (nchar(v[i]))) {
  numberOfTimes &lt;- numberOfTimes + 1
  }
  }
  return(numberOfTimes)
  }
  }
  </code></pre>
  
  <p>missing value where TRUE/FALSE needed.</p>
  
  <p>I do not know why this happens.</p>