1

I have:

df <-tibble(a=rep(NA, 3), b = c(T,NA,F), c =c("a", NA, "v"))

# A tibble: 3 x 3
  a     b     c    
  <lgl> <lgl> <chr>
1 NA    TRUE  a    
2 NA    NA    NA   
3 NA    FALSE v   

and would like to remove all rows being all NA to get this:

# A tibble: 2 x 3
  a     b     c    
  <lgl> <lgl> <chr>
1 NA    TRUE  a    
2 NA    FALSE v    

I would like to have a solution using dplyr in a pipe:

df %>% ???

Note: This question is different from: Remove rows with all or some NAs (missing values) in data.frame because in the linked question is at least one not NA value per row.

Ruediger Ziege
  • 300
  • 3
  • 17

1 Answers1

3

This can be done using filter_all:

df %>% filter_all(any_vars(!is.na(.)))
Ruediger Ziege
  • 300
  • 3
  • 17