na_const: Replace missing values with a constant

Description Usage Arguments Examples

View source: R/simple.R

Description

Replace missing values with a constant

Usage

1
2
3
4
5
6
7
na_const(x, value = mean(x, na.rm = TRUE))

na_mean(x, trim = 0)

na_median(x)

na_mode(x)

Arguments

x

a vector.

value

scalar used as a replacement value.

trim

the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint. See mean.

Examples

1
2
3
4
5
x <- c(NA, 1, 2, NA, 4, NA, NA, 7, NA)
na_mean(x)
na_median(x)
na_mode( c(2, 1, 2, NA, 4, NA, NA, 3, 2, 1, NA) )
na_mode( c( NA, "a", NA, "b", "a", NA, NA) )

twolodzko/misster documentation built on May 24, 2019, 2:54 p.m.