A convenient way to obtain percent missingness column-wise.

percent_missing(df, grouping_cols = NULL, exclude_cols = NULL)

Arguments

df

A valid R `object` for which the percentage of missing values is required.

grouping_cols

A character vector. If supplied, one can provide the columns by which to group the data.

exclude_cols

A character vector indicating columns to exclude when returning results.

Value

An object of the same class as x showing the percentage of missing values.

Examples

test <- data.frame(ID= c("A","B","A","B","A","B","A"), 
Vals = c(NA,25,34,NA,67,NA,45))
percent_missing(test,grouping_cols = "ID")
#> # A tibble: 2 x 2
#>   ID     Vals
#>   <chr> <dbl>
#> 1 A      25  
#> 2 B      66.7
percent_missing(airquality)
#>      Ozone  Solar.R Wind Temp Month Day
#> 1 24.18301 4.575163    0    0     0   0
percent_missing(airquality,exclude_cols = c("Day","Temp"))
#>      Ozone  Solar.R Wind Month
#> 1 24.18301 4.575163    0     0