Drop rows containing missing values

drop_na(data, ...)

Arguments

data

A data frame.

...

<tidy-select> Columns to inspect for missing values.

Examples

library(dplyr) df <- tibble(x = c(1, 2, NA), y = c("a", NA, "b")) df %>% drop_na()
#> # A tibble: 1 x 2 #> x y #> <dbl> <chr> #> 1 1 a
df %>% drop_na(x)
#> # A tibble: 2 x 2 #> x y #> <dbl> <chr> #> 1 1 a #> 2 2 NA
vars <- "y" df %>% drop_na(x, any_of(vars))
#> # A tibble: 1 x 2 #> x y #> <dbl> <chr> #> 1 1 a