replace_na: Replaces NA values

Description Usage Arguments Examples

View source: R/replace_na.R

Description

Replaces NA values in a vector according to a given method. Specific non-NA values can be considered as NA, if given in as_na.

Usage

1
replace_na(x, as_na = c(NULL), method = NULL)

Arguments

x

Numeric or Character/factor vector.

as_na

Numeric or Character, specifies values that may be considered as NA.

method

Character, the method used for choosing the replacement ("NULL", "random", "mode", "normal"). Accepts numeric value if x is numeric. Method must be compatible with x class.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 

replace_na(c(1, 2, NA, 4, 5, 6), method = 3)
replace_na(c(1, 3.5, 9, 2.8, 5.6, 10.4, 0.7, 2.4, 5.5, NA), method = "normal")
replace_na(c(1, 3.5, 9, 2.8, 5.6, 10.4, 0.7, 2.4, 5.5, NA), method = "random")
replace_na(c("A", "B", "A", "F", "K", "B", "O", "A"), method = "mode")


## End(Not run)

Andros-Spica/cerUB documentation built on June 9, 2020, 9:22 p.m.