detrend: De-trends a numeric vector

Description Usage Arguments Value

Description

Given a numeric vector, it calculates a rolling median and then from each element, it subtracts the local median. The window for the median is centered on the element, so if the size is 5, it takes the element itself and the elements up to ±2 positions from it. If the size is even, it's rounded down (e.g. window_size = 6 is the same as window_size = 5).

Usage

1
detrend(x, window_size = 5)

Arguments

x

A numeric vector.

window_size

A length for the rolling window to calculate the median.

Value

A numeric vector, de-trended.


KleberNeves/CRMilestones documentation built on Dec. 18, 2021, 3:35 a.m.