title: "missing value where TRUE/FALSE needed" Error in if statement in R
body: <p>I am trying to count and print the cases in which the values in second and third columns of my dataframe named 'DATA'. 
  But I have "missing value where TRUE/FALSE needed" Error.</p>
  
  <p>Could you help me please? How can I write my condition in if statement without getting this error?</p>
  
  <p>My Code:    </p>
  
  <pre><code>deneme&lt;-function(id=vector()){
  i&lt;-1
  counter&lt;-1
  sulfate&lt;-DATA[,2]
  nitrate&lt;-DATA[,3]
  while (DATA[i,4] == DATA[i+1,4]){
  if(DATA[i,2] != NA &amp; DATA[i,3] != NA){
  counter&lt;-counter+1
  
  }
  i&lt;-i+1
  }
  
  print(counter)  
  }
  </code></pre>