This adds a column named "any_miss" (by default) that describes whether
there are any missings in all of the variables (default), or whether any
of the specified columns, specified using variables names or dplyr verbs,
starts_with
, contains
, ends_with
, etc. By default the added column
will be called "any_miss_all", if no variables are specified, otherwise,
if variables are specified, the label will be "any_miss_vars" to indicate
that not all variables have been used to create the labels.
Arguments
- data
data.frame
- ...
Variable names to use instead of the whole dataset. By default this looks at the whole dataset. Otherwise, this is one or more unquoted expressions separated by commas. These also respect the dplyr verbs
starts_with
,contains
,ends_with
, etc. By default will add "_all" to the label if left blank, otherwise will add "_vars" to distinguish that it has not been used on all of the variables.- label
label for the column, defaults to "any_miss". By default if no additional variables are listed the label col is "any_miss_all", otherwise it is "any_miss_vars", if variables are specified.
- missing
character a label for when values are missing - defaults to "missing"
- complete
character character a label for when values are complete - defaults to "complete"
Value
data.frame with data and the column labelling whether that row (for those variables) has any missing values - indicated by "missing" and "complete".
Examples
airquality %>% add_any_miss()
#> # A tibble: 153 × 7
#> Ozone Solar.R Wind Temp Month Day any_miss_all
#> <int> <int> <dbl> <int> <int> <int> <chr>
#> 1 41 190 7.4 67 5 1 complete
#> 2 36 118 8 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 missing
#> 6 28 NA 14.9 66 5 6 missing
#> 7 23 299 8.6 65 5 7 complete
#> 8 19 99 13.8 59 5 8 complete
#> 9 8 19 20.1 61 5 9 complete
#> 10 NA 194 8.6 69 5 10 missing
#> # ℹ 143 more rows
airquality %>% add_any_miss(Ozone, Solar.R)
#> # A tibble: 153 × 7
#> Ozone Solar.R Wind Temp Month Day any_miss_vars
#> <int> <int> <dbl> <int> <int> <int> <chr>
#> 1 41 190 7.4 67 5 1 complete
#> 2 36 118 8 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 missing
#> 6 28 NA 14.9 66 5 6 missing
#> 7 23 299 8.6 65 5 7 complete
#> 8 19 99 13.8 59 5 8 complete
#> 9 8 19 20.1 61 5 9 complete
#> 10 NA 194 8.6 69 5 10 missing
#> # ℹ 143 more rows