fillMissing: Fill missing values

Description Usage Arguments Value See Also Examples

View source: R/utilities-data-validation.R

Description

Impute uniformly in the range of the provided variable

Usage

1
fillMissing(x, varType, imputeRng = NULL, categories = NULL)

Arguments

x

Vector with missing values to impute

varType

Character specifying the variable type

categories

Set of possible categories from which to choose, default NULL

lower

Numeric lower bound, default NULL

upper

Numeric upper bound, default NULL

Value

Vector x with missing values imputed

See Also

dpUnif

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# numeric example
y <- rnorm(100)
y[sample(1:100, size=10)] <- NA
y_imputed <- fillMissing(x=y, varType='numeric', lower=-1, upper=1)

# categorical example
cats <- as.factor(c('dog', 'zebra', 'bird', 'hippo'))
s <- sample(cats, size=100, replace=TRUE)
s[sample(1:100, size=10)] <- NA
s_imputed <- fillMissing(x=s, varType='factor', categories=cats)

privacytoolsproject/PSI-Library documentation built on Feb. 17, 2020, 2:03 p.m.