title: Function in R missing missing value where TRUE/FALSE needed - not is.na()
body: <p>I am trying to sort these school grades in a variable but, I am running into this "missing value where TRUE/FALSE needed" initially I thought - "Okay this is going to be the NA values." Unfortunately I added the recommended in other posts if is.na(x) and I still get the error. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>convert.factor &lt;- function(val){
    if(val &lt;= 1.49){
      return("F/E")
    } else if(val &gt;= 1.50 &amp; val &lt;= 2.49) {
      return("D")
    } else if(val &gt;= 2.50 &amp; val &lt;= 3.49) {
      return("C")
    } else if(val &gt;= 3.50 &amp; val &lt;= 4.49) {
      return("B")
    } else if (val &gt;= 4.50 &amp; val &lt;= 5.00){
      return("A")
    } else if ( is.na(val)){
      return("NA")
    }
  }
  
  WaveOne$GPA &lt;- sapply(WaveOne$V139, convert.factor)
  </code></pre>
  
  <p>Here are some discriptive statistics on the variable itself:
  <a href="https://i.stack.imgur.com/hZQ09.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hZQ09.png" alt="IMAGE"></a></p>