title: r - check if every column is na
body: <p>I have a list of columns within a dataframe which where i want to check if all those columns are <code>NA</code> and create a new column which tells me if they are <code>NA</code> or not.</p>
  
  <p>Here is an example of it working with one column, where <code>Any_Flag</code> is my new column:</p>
  
  <pre><code>ItemStats_2014$Any_Flag &lt;- ifelse(is.na(ItemStats_2014$Item_Flag_A), "Y", "N")
  </code></pre>
  
  <p>When i try to run the check over multiple columns, I am getting what i expect:</p>
  
  <pre><code>ItemStats_2014$Any_Flag &lt;- ifelse(all(is.na(ItemStats_2014[ ,grep("Flag", names(ItemStats_2014), value = T)])), "Y", "N")
  </code></pre>
  
  <p>It returns everything to be false or "N".</p>