Maturing lifecycle

Removes the mean, the median or the mode from the series.

demean(x, na.rm = getOption("transx.na.rm"))

demedian(x, na.rm = getOption("transx.na.rm"))

demode(x, na.rm = getOption("transx.na.rm"))

Arguments

x

[univariate vector]

Univariate vector, numeric or ts object with only one dimension.

na.rm

[logical(1): getOption("transx.na.rm")]

A value indicating whether NA values should be stripped before the computation proceeds.

Value

Returns a vector with the same class and attributes as the input vector.

Examples

x <- c(2,5,10,20,30) summary(x)
#> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 2.0 5.0 10.0 13.4 20.0 30.0
demean(x)
#> [1] -11.4 -8.4 -3.4 6.6 16.6
demedian(x)
#> [1] -8 -5 0 10 20
demode(x)
#> [1] -4.795224 -1.795224 3.204776 13.204776 23.204776