Skip to contents

Set a proportion or number of missing values

Usage

set_prop_miss(x, prop = 0.1)

set_n_miss(x, n = 1)

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

Value

vector with missing values added

Examples

vec <- rnorm(5)
set_prop_miss(vec, 0.2)
#> [1] -0.65662615 -0.64975149  0.09030152          NA  0.74846478
set_prop_miss(vec, 0.4)
#> [1] -0.6566262 -0.6497515         NA -1.3162772         NA
set_n_miss(vec, 1)
#> [1] -0.6566262 -0.6497515         NA -1.3162772  0.7484648
set_n_miss(vec, 4)
#> [1]        NA        NA        NA -1.316277        NA