Learn R Programming

missRanger (version 2.6.1)

generateNA: 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)

Value

x with missing values.

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.

seed

An integer seed.

Examples

Run this code
generateNA(1:10, p = 0.5)
head(generateNA(iris, p = 0.2))

Run the code above in your browser using DataLab