title: in R how do i get mapply to ignore the NA on elements passed to the function
body: <p>I created a simple function to determine the difference between 2 variables in a dataframe </p>
  
  <pre><code> detYearDisc &lt;- function(x,y)
   {
      if (x &lt; y)
            return("L")
      if (x &gt; y)
            return("G")
      if (x == y) 
            return("N")
  
  }
  </code></pre>
  
  <p>The dataframe df can contain NA on x or y or both . When I run the mapply function </p>
  
  <pre><code>df$DiscInd = mapply(detYearDisc, df$X,df$Y)
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>Error in if (x &lt; y) return("L") : missing value where TRUE/FALSE needed
  </code></pre>
  
  <p>Is this because I got NA on x or y value?? </p>