Learn R Programming

naniar (version 0.0.3.9901)

add_prop_miss: Add column containing proportion of missing data values

Description

It can be useful when doing data analysis to add the proportion of missing data values into your dataframe. add_prop_miss adds a column named "prop_miss", which contains the proportion of missing values in that row.

Usage

add_prop_miss(data)

Arguments

data
a dataframe

Value

a dataframe

Examples

Run this code

library(magrittr)
airquality %>% add_prop_miss()

# this can be applied to model the proportion of missing data
# as in Tierney et al bmjopen.bmj.com/content/5/6/e007450.full
library(rpart)
library(rpart.plot)

airquality %>%
add_prop_miss() %>%
rpart(prop_miss ~ ., data = .) %>%
prp(type = 4,
    extra = 101,
    prefix = "prop_miss = ")

Run the code above in your browser using DataLab