Skip to contents

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))

Arguments

dat

A data frame or tibble from which rows with missing values should be dropped.

.columns

Columns to check for missing values. Supports tidy selection syntax. Defaults to NULL, meaning all columns are checked.

Value

A data frame or tibble with rows containing missing values in the specified columns removed.

See also

Examples

df <- data.frame(x = c(1, 2, NA, 4), y = c(NA, 5, 6, 7))
dta_gtable(df)
x y
1
2 5

6
4 7
# 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