Learn R Programming

mde (version 0.2.1)

drop_na_if: Conditon based dropping of columns with missing values

Description

"drop_na_if" provides a simple way to drop columns with missing values if they meet certain criteria/conditions.

Usage

drop_na_if(df, sign = "gteq", percent_na = 50, keep_columns = NULL, ...)

Arguments

df

A data.frame object

sign

Character. One of gteq,lteq,lt,gt or eq which refer to greater than(gt) or equal(eq) or less than(lt) or equal to(eq) respectively.

percent_na

The percentage to use when dropping columns with missing values

keep_columns

Columns that should be kept despite meeting the target percent_na criterion(criteria)

...

Other arguments to "percent_missing"

Value

A data.frame object with columns that meet the target criteria dropped

See Also

percent_missing

Examples

Run this code
# NOT RUN {
head(drop_na_if(airquality, percent_na = 24))
#drop columns that have less tan or equal to 4%
head(drop_na_if(airquality,sign="lteq", percent_na = 4))
# Drop all except with greater than oe equal to 4% missing but keep Ozone
head(drop_na_if(airquality, sign="gteq",percent_na = 4, keep_columns = "Ozone"))
# }

Run the code above in your browser using DataLab