drop_if_all_na.Rd
Remove a row if all values on selected columns, or by default, on all columns, are missing, i.e. have values of NA or NaN.
drop_if_all_na(data, ...)
A data frame, possibly with some rows dropped.
The drop_na function will remove any row if it has any NA in selected columns.
By default, it will remove the row there is any NA or NaN in any column.
This drop_if_all_na
function is similar but removes the row only if all values in the selected columns are NA or NaN.
As with drop_na, by default it will use all columns.
In other words, by default, drop_if_all_na
removes any row if all values on that row are NA or NaN.
data_df <- data.frame(x = c(1, 2, NA, NA), y = c(2, NA, 5, NA))
drop_if_all_na(data_df)
#> x y
#> 1 1 2
#> 2 2 NA
#> 3 NA 5
drop_if_all_na(data_df, x)
#> x y
#> 1 1 2
#> 2 2 NA
drop_if_all_na(data_df, y)
#> x y
#> 1 1 2
#> 2 NA 5
drop_if_all_na(data_df, x, y)
#> x y
#> 1 1 2
#> 2 2 NA
#> 3 NA 5
drop_if_all_na(data_df, x:y)
#> x y
#> 1 1 2
#> 2 2 NA
#> 3 NA 5
drop_if_all_na(data_df, starts_with('x'), ends_with('y'))
#> x y
#> 1 1 2
#> 2 2 NA
#> 3 NA 5