Learn R Programming

missCforest (version 0.0.8)

generateNA: Generate Missing Values Completely at Random

Description

Introducing a proportion of missing values given a data.frame under Missing Completely at Random mechanism (MCAR).

Usage

generateNA(dat, pmiss = 0.2, seed = 123)

Value

data.frame with the desired proportion of missing values.

Arguments

dat

complete data.frame.

pmiss

proportion of NA.

seed

seed value to ensure reproducibility.

Details

This function is made only for experimental purpose. Whithout specifying the columns (i.e. variables), missing values are introduced to all columns of the dataset.

Examples

Run this code

data(iris)
# introduce 30% of NA
irisNA <- generateNA(iris, 0.3)
# check the proportion of NA
 mean(is.na(irisNA))

Run the code above in your browser using DataLab