njtierney / naniar

Tidy data structures, summaries, and visualisations for missing data
http://naniar.njtierney.com/
Other
651 stars 54 forks source link

add_label_shadow and add_label_missing should allow for custom labels #214

Closed njtierney closed 6 years ago

njtierney commented 6 years ago

Current behaviour:

library(naniar)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
airquality %>%
 mutate(is_missing = label_missings(airquality)) %>%
 head()
#>   Ozone Solar.R Wind Temp Month Day  is_missing
#> 1    41     190  7.4   67     5   1 Not Missing
#> 2    36     118  8.0   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

Created on 2018-09-10 by the reprex package (v0.2.0.9000).

Proposed behaviour:

# proposed behaviour
airquality %>%
 mutate(is_missing = label_missings(airquality,
                                    missing = "miss",
                                    complete = "complete")) %>%
 head()

#>   Ozone Solar.R Wind Temp Month Day  is_missing
#> 1    41     190  7.4   67     5   1    complete
#> 2    36     118  8.0   72     5   2    complete
#> 3    12     149 12.6   74     5   3    complete
#> 4    18     313 11.5   62     5   4    complete
#> 5    NA      NA 14.3   56     5   5        miss
#> 6    28      NA 14.9   66     5   6        miss

In the future this could also be extended to allow for any type of special missing - which I will lodge as an issue for the next milestone