Description Usage Arguments Value Examples
Replaces NA values with a defined alternative. For a numeric vector, this can be either the mean or median of the vector. For a character or factor vector, this will be the mode.
1 | replace_na(x, method)
|
x |
Vector that contains NA values. |
method |
Replacement method for NA values. For a numeric vector the user can choose between 'mean' and 'median'. For character or factor vectors the mode is automatically chosen. |
A vector without NA values.
1 2 3 4 5 6 7 | x <- c(1, 3, 5, 5, 6, NA, 10)
replace_na(x)
# 1 3 5 5 6 5 10
x <- c("Cat", "Dog", "Catdog", NA, "Cat")
replace_na(x)
# "Cat" "Dog" "Catdog" "Cat" "Cat"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.