Drop rows with missing values and issue a warning
Source:R/dta_drop_na_with_warning.R
dta_drop_with_warning.Rd
dta_drop_with_warning()
removes rows with missing values (NA) from
specified columns in a data frame or tibble. If any rows are dropped,
a warning is issued indicating the number of rows removed.
Usage
dta_drop_with_warning(dat, .columns = names(dat))
Examples
df <- data.frame(x = c(1, 2, NA, 4), y = c(NA, 5, 6, 7))
dta_gtable(df)
# Drop rows with NA values in any column and issue a warning
dta_drop_with_warning(df)
#> Warning: 2 rows with missing values (NA) were dropped
#> # A tibble: 2 × 2
#> x y
#> <dbl> <dbl>
#> 1 2 5
#> 2 4 7
# Drop rows with NA values in a specific column and issue a warning
dta_drop_with_warning(df, .columns = x)
#> Warning: 1 row with missing values (NA) was dropped
#> # A tibble: 3 × 2
#> x y
#> <dbl> <dbl>
#> 1 1 NA
#> 2 2 5
#> 3 4 7