missing: Inserts NAs throughout a data frame at random

Description Usage Arguments Details Value See Also

View source: R/utils.R

Description

Inserts NAs throughout a data frame at random

Usage

1
missing(x, na_prob = 0.1, cols = seq_along(x), symm = F)

Arguments

x

Data frame or vector.

na_prob

the probability of missing values per variable in the data frame. Default is 0.1, i.e. each variable will have 10% NAs.

cols

numeric. In which columns to insert NAs. Default is all columns. To leave out the first column, use cols = -1.

symm

logical. whether the missing values should be inserted symmetrically, i.e., whether each column should contain the same number of NAs.

Details

Function is a modified version of 'r_na' and r_na_vector' from the 'wakefield' package. It adds the functionality to add NAs asymmetrically to a data frame, meaning the number of NAs per column will vary.

Value

Returns the original data frame with NAs inserted. The default settings returns a data frame with data missing completely at random.

See Also

r_na


bbartholdy/hitchr documentation built on Nov. 21, 2021, 9:16 p.m.