title: R remove groups with only NAs
body: <p>I have a dataframe similar to the one generated by the following structure:</p>
  
  <pre><code>library(dplyr)
  
  df1 &lt;- expand.grid(region   = c("USA", "EUR", "World"),
                    time     = c(2000, 2005, 2010, 2015, 2020),
                    scenario = c("policy1", "policy2"),
                    variable = c("foo", "bar"))
  
  df2 &lt;- expand.grid(region   = c("USA", "EUR", "World"),
                    time     = seq(2000, 2020, 1),
                    scenario = c("policy1", "policy2"),
                    variable = c("foo", "bar"))
  
  df2 &lt;- filter(df2, !(time %in% c(2000, 2005, 2010, 2015, 2020)))
  
  df1$value &lt;- rnorm(dim(df1)[1], 1.5, 1)
  df1[df1 &lt; 0] &lt;- NA
  df2$value &lt;- NA
  
  df1[df1$region == "World" &amp; df1$variable == "foo", "value"] &lt;- NA
  
  df &lt;- rbind(df1, df2)
  
  rm(df1, df2)
  
  df &lt;- arrange(df, region, scenario, variable, time)
  </code></pre>
  
  <p><code>df</code> contains two "types" of NA. For one combination of region and variable (World/foo), there is no data at all. For all other combinations, we have NAs for all years except 2000, 2005, 2010, 2015, 2020.</p>
  
  <p>I need a filter that removes the combinations of regions and variable that do only contain NAs, but keeps those combinations that only contain a few NAs. Background is that I want to apply a linear interpolation to compute the missing values for the latter by combining <code>dplyr</code> and functionality from the <code>zoo</code>-package (for the interpolation) using something like this:</p>
  
  <pre><code>df &lt;- group_by(df, region, scenario, variable, time) %&gt;%
        mutate(value = zoo::na.approx(value)) %&gt;% ungroup()
  </code></pre>
  
  <p>The group containing only NAs leads to <code>na.approx</code> returning an error since it cannot function only with NAs.</p>