title: Simple if-else loop in R
body: <p>Can someone tell me what is wrong with this if-else loop in R? I frequently can't get if-else loops to work. I get an error:</p>
  
  <pre><code>if(match('SubjResponse',names(data))==NA) {
      observed &lt;- data$SubjResponse1
  }
  else {
      observed &lt;- data$SubjResponse
  }
  </code></pre>
  
  <p>Note that <code>data</code> is a data frame.</p>
  
  <p>The error is</p>
  
  <pre><code>Error in if (match("SubjResponse", names(data)) == NA) { : 
    missing value where TRUE/FALSE needed
  </code></pre>