Drop rows containing missing values

drop_na(.df, ...)

Arguments

.df

A data.frame or data.table

...

Optional: A selection of columns. If empty, all variables are selected. tidyselect compatible.

Examples

df <- data.table(
  x = c(1, 2, NA),
  y = c("a", NA, "b")
)

df %>%
  drop_na()
#> # A tidytable: 1 × 2
#>       x y    
#>   <dbl> <chr>
#> 1     1 a    

df %>%
  drop_na(x)
#> # A tidytable: 2 × 2
#>       x y    
#>   <dbl> <chr>
#> 1     1 a    
#> 2     2 NA   

df %>%
  drop_na(where(is.numeric))
#> # A tidytable: 2 × 2
#>       x y    
#>   <dbl> <chr>
#> 1     1 a    
#> 2     2 NA