title: Removing rows with multiple NAs with group_by in dplyr
body: <p>I have this toy data-frame:</p>
  
  <pre><code>df &lt;- data.frame(id=c(1,1,2,3,4,4),p_id=c(1001,1001,1002,1003,1004,1004),x=c(1,NA,1,2,NA,1),y=c(NA,5,4,NA,6,NA),z=c(NA,NA,2,3,NA,4))
  
  id p_id  x  y   z
  1  1001  1  NA  NA
  1  1001 NA  5   NA
  2  1002  1  4    2
  3  1003  2  NA   3
  4  1004 NA  6   NA
  4  1004  1  NA   4
  </code></pre>
  
  <p>I would like to get the final output with unique 'p_id' rows and undesired NA values from x,y, and z (ideally, should work on any number of columns) removed. Example output:</p>
  
  <pre><code>p_id    x    y     z
  1001    1    5     NaN
  1002    1    4     2
  1003    2  NaN     3
  1004    1    6     4
  </code></pre>
  
  <p>I am doing this quick workaround (not sure best approach):  </p>
  
  <pre><code>df %&gt;% select(-id) %&gt;% group_by(p_id) %&gt;% summarise_all(funs(mean),na.rm=T) %&gt;% ungroup()
  </code></pre>
  
  <p>However, this workaround is very slow when applied on large dataframe (2500 x 650) and it creates unwanted NAs for the normal cells. Also for context, the duplicated p_id rows with NA in this df are coming from the spread function. </p>