Learn R Programming

naniar (version 1.0.0)

set-prop-n-miss: Set a proportion or number of missing values

Description

Set a proportion or number of missing values

Usage

set_prop_miss(x, prop = 0.1)

set_n_miss(x, n = 1)

Value

vector with missing values added

Arguments

x

vector of values to set missing

prop

proportion of values between 0 and 1 to set as missing

n

number of values to set missing

Examples

Run this code
vec <- rnorm(5)
set_prop_miss(vec, 0.2)
set_prop_miss(vec, 0.4)
set_n_miss(vec, 1)
set_n_miss(vec, 4)

Run the code above in your browser using DataLab