movQt: Moving Quantile(Moving Median, Moving Minimum, Moving...

Description Usage Arguments Details Value Functions Examples

View source: R/RcppExports.R

Description

This function returns a moving quantile of the given vector.

Usage

1
2
3
4
movQt(vec, n = 1L, prob = 0.5, ss = 1L, na_rm = FALSE, sizeD = FALSE,
  align = "left")

movQtr(vec, n = 1L, prob = 0.5, ss = 1L, na_rm = FALSE, sizeD = FALSE)

Arguments

vec

A numeric vector.

n

An integer: moving window size, with 1 as default

prob

A number: between 0 and 1, meaning prob quantile

ss

An integer: step size, only calculating at points with an equal distance ss. Namely, there are ss-1 number between each two 'consecutive' points

na_rm

logical. Should missing values (including NaN) be removed?

sizeD

logical. Only applied when ss > 1, it decides whether to get a result of smaller size. If sizeD = T, align does not affect the output.

align

A string denotes how to align the moving average, three options: "left", "middle", "right"

Details

Despite of Efficient computation, this function can return different kinds of moving quantile, e.g. moving median(prob = 0.5), moving minimum(prob = 0), and moving maximum(prob = 1). It can handle potential missing values(NA or NaN) in the vec. When we move to one specific fragment, missing values can be removed by setting na_rm = TRUERUE. If all values of this fragment is missing, it will return NA.
In terms of the quantile algorithm, please consult type 7 in function quantile.

Value

This function returns a vector whose length is the same as that of vec or is ceiling((L - n + 1)/ss), (when sizeD = T), where L is the length of vec.

Functions

Examples

1
2
3
movQt(vec = c(1, 4, 3, NA, 8, 4, 5, 9, 6, 0), n = 3, ss = 4, na_rm = TRUE, align = "right")
movQt(vec = c(1, 4, 3, NA, 8, 4, 5, 9, 6, 0), n = 3, na_rm = TRUE, align = "right")
movQt(vec = c(1, 4, 3, NA, NA, NA, 5, 9, 6, 0), n = 3, ss = 4, na_rm = TRUE, align = "middle")

RcppMovStat documentation built on Jan. 30, 2018, 5:04 p.m.