simulate_missings {NADIA}R Documentation

Generate MCAR missings in dataset.

Description

Function generates random missing values in given dataset according to set parameters.

Usage

simulate_missings(
  df,
  per_missings,
  per_instances_missings = NULL,
  per_variables_missings = NULL,
  variables_with_missings = NULL
)

Arguments

df

Data.frame or data.table where missing values will be generated

per_missings

Overall percentage of missing values generated in dataset. Must be set every time.

per_instances_missings

Percentage of instances which will have missing values.

per_variables_missings

Percentage of variables which will have missing values.

variables_with_missings

Only when 'per_variables_missings' is 'NULL'. Vector of column indexes where missings will be generated.

Value

Dataset with generated missings.

Examples

{
  data_NA <- simulate_missings(iris, 20)

  # check
  sum(is.na(data_NA)) > 0
}

[Package NADIA version 0.4.2 Index]