Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

caTools-internal

internal function


Description

internal function

Usage

EndRule(x, y, k, dimx,
             endrule=c("NA", "trim", "keep", "constant", "func"), 
             align = c("center", "left", "right"), Func, ...)

Arguments

x

numeric vector of length n

k

width of moving window; must be an integer between one and n.

dimx

original dimension of x (usually dim(x)) used to choose dimentions of the output.

endrule

character string indicating how the values at the beginning and the end, of the data, should be treated. Only first and last k2 values at both ends are affected, where k2 is the half-bandwidth k2 = k %/% 2.

  • "mad" - applies the mad function to smaller and smaller sections of the array. Equivalent to: for(i in 1:k2) out[i]=mad(x[1:(i+k2)]).

  • "trim" - trim the ends; output array length is equal to length(x)-2*k2 (out = out[(k2+1):(n-k2)]). This option mimics output of apply (embed(x,k),1,FUN) and other related functions.

  • "keep" - fill the ends with numbers from x vector (out[1:k2] = x[1:k2]). This option makes more sense in case of smoothing functions, kept here for consistency.

  • "constant" - fill the ends with first and last calculated value in output array (out[1:k2] = out[k2+1])

  • "NA" - fill the ends with NA's (out[1:k2] = NA)

  • "func" - same as "mad" option except that implemented in R for testing purposes. Avoid since it can be very slow for large windows.

y

numeric vector of length n, which is partially filled output of one of the run functions. Function EndRule will fill the remaining beginning and end sections using method chosen by endrule argument.

align

specifies whether result should be centered (default), left-aligned or right-aligned.

Func

Function name that EndRule will use in case of endrule="func".

...

Additional parameters to Func that EndRule will use in case of endrule="func".

Value

Returns a numeric vector of the same length as x. Only in case of endrule="trim".the output will be shorter.

Author(s)

Jarek Tuszynski (SAIC) jaroslaw.w.tuszynski@saic.com


caTools

Tools: Moving Window Statistics, GIF, Base64, ROC AUC, etc

v1.18.2
GPL-3
Authors
Jarek Tuszynski <jaroslaw.w.tuszynski@saic.com>
Initial release
2021-03-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.