title: Check row-wise NA sum in R data.table
body: <p><strong>Problem:</strong> I want to check if a row contains solely of NA's in a <code>data.table</code> object.
  Currently, I have an implementation depending on <code>apply</code>. Is there a more efficient while readable solution?</p>
  <p>Any improvements and ideas are welcome! Thanks</p>
  <pre><code>dt &lt;- data.table(
    x = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;),
    y = c(&quot;true&quot;, NA, NA, &quot;true&quot;),
    z = c(NA, NA, &quot;true&quot;, &quot;true&quot;),
    a = c(NA, NA, NA, &quot;ha&quot;)
  )
  
  # Current Code:
  idx &lt;- apply(dt[, c(2:ncol(dt)), with = FALSE], 1, function(x) all(is.na(x)))
  dt &lt;- dt[!idx] 
  
  # Code Attempt 1 (not so nice due to temp na_count column)
  rel_cols &lt;- names(dt)[!names(dt) %in% c(&quot;x&quot;)]
  dt[, na_count := rowSums(is.na(.SD)), .SDcols = rel_cols][na_count &lt; (ncol(dt) - 2)]
  </code></pre>