generateNA {missRanger}R Documentation

Adds Missing Values

Description

Takes a vector, matrix or data.frame and replaces some values by NA.

Usage

generateNA(x, p = 0.1, seed = NULL)

Arguments

x

A vector, matrix or data.frame.

p

Proportion of missing values to add to x. In case x is a data.frame, p can also be a vector of probabilities per column or a named vector (see examples).

seed

An integer seed.

Value

x with missing values.

Examples

generateNA(1:10, p = 0.5, seed = 3345)
generateNA(rep(Sys.Date(), 10))
generateNA(cbind(1:10, 10:1), p = 0.2)
head(generateNA(iris))
head(generateNA(iris, p = 0.2))
head(generateNA(iris, p = c(0, 1, 0.5, 0.5, 0.5)))
head(generateNA(iris, p = c(Sepal.Length = 1)))
head(generateNA(iris, p = c(Species = 0.2, Sepal.Length = 0.5)))

[Package missRanger version 2.5.0 Index]