Skip to contents

Add a column describing if there are any missings in the dataset

Usage

add_label_missings(data, ..., missing = "Missing", complete = "Not Missing")

Arguments

data

data.frame

...

extra variable to label

missing

character a label for when values are missing - defaults to "Missing"

complete

character character a label for when values are complete - defaults to "Not Missing"

Value

data.frame with a column "any_missing" that is either "Not Missing" or "Missing" for the purposes of plotting / exploration / nice print methods

Examples


airquality %>% add_label_missings()
#> # A tibble: 153 × 7
#>    Ozone Solar.R  Wind  Temp Month   Day any_missing
#>    <int>   <int> <dbl> <int> <int> <int> <chr>      
#>  1    41     190   7.4    67     5     1 Not Missing
#>  2    36     118   8      72     5     2 Not Missing
#>  3    12     149  12.6    74     5     3 Not Missing
#>  4    18     313  11.5    62     5     4 Not Missing
#>  5    NA      NA  14.3    56     5     5 Missing    
#>  6    28      NA  14.9    66     5     6 Missing    
#>  7    23     299   8.6    65     5     7 Not Missing
#>  8    19      99  13.8    59     5     8 Not Missing
#>  9     8      19  20.1    61     5     9 Not Missing
#> 10    NA     194   8.6    69     5    10 Missing    
#> # ℹ 143 more rows
airquality %>% add_label_missings(Ozone, Solar.R)
#> # A tibble: 153 × 7
#>    Ozone Solar.R  Wind  Temp Month   Day any_missing
#>    <int>   <int> <dbl> <int> <int> <int> <chr>      
#>  1    41     190   7.4    67     5     1 Not Missing
#>  2    36     118   8      72     5     2 Not Missing
#>  3    12     149  12.6    74     5     3 Not Missing
#>  4    18     313  11.5    62     5     4 Not Missing
#>  5    NA      NA  14.3    56     5     5 Missing    
#>  6    28      NA  14.9    66     5     6 Missing    
#>  7    23     299   8.6    65     5     7 Not Missing
#>  8    19      99  13.8    59     5     8 Not Missing
#>  9     8      19  20.1    61     5     9 Not Missing
#> 10    NA     194   8.6    69     5    10 Missing    
#> # ℹ 143 more rows
airquality %>% add_label_missings(Ozone, Solar.R, missing = "yes", complete = "no")
#> # A tibble: 153 × 7
#>    Ozone Solar.R  Wind  Temp Month   Day any_missing
#>    <int>   <int> <dbl> <int> <int> <int> <chr>      
#>  1    41     190   7.4    67     5     1 no         
#>  2    36     118   8      72     5     2 no         
#>  3    12     149  12.6    74     5     3 no         
#>  4    18     313  11.5    62     5     4 no         
#>  5    NA      NA  14.3    56     5     5 yes        
#>  6    28      NA  14.9    66     5     6 yes        
#>  7    23     299   8.6    65     5     7 no         
#>  8    19      99  13.8    59     5     8 no         
#>  9     8      19  20.1    61     5     9 no         
#> 10    NA     194   8.6    69     5    10 yes        
#> # ℹ 143 more rows