title: Removing/ignoring NA values in an if loop
body: <p>So I have this simple if loop</p>
  
  <pre><code>chick&lt;-lapply(1:length(t),function(i){
  if(t[[i]]&lt;0.01){
  chick=1
  }else 0 
  })
  </code></pre>
  
  <p>So basically when t&lt;0.01 it print outs 1 if not it prints 0 but there are times when I have data that has NA values like the one below....how can I assign the NA values 0 as well coz I'll get an error similar to this if I dont: </p>
  
  <pre><code>Error in if (t[[i]] &lt; 0.01) { : missing value where TRUE/FALSE needed
  </code></pre>
  
  <p>Here is a sample output from data called 't'</p>
  
  <pre><code>[[1]]
  [1] NA
  
  [[2]]
  [1] NA
  
  [[3]]
  [1] 0.01
  </code></pre>
  
  <p>thanks again</p>