padding: Aperiodically increases the span of a given X-Y dataset. See...

View source: R/padding.R

paddingR Documentation

Aperiodically increases the span of a given X-Y dataset.
See also periodify

Description

Adds an integer no. of periods of the X-Y dataset to itself.
The no. of integer periods by which the X-Y dataset is increased in the forward and backward direction is specified by "fwd" and "bwd" arguments.
Hence, if L is the length of the X-Y dataset, the new dataset has a length of "L*(fwd + bwd + 1)".
The returned dataset is always a dataframe

Usage

df <- padding(X, Y, fwd, bwd)
df <- padding(X, Y, fwd, bwd, pad.type = 'default')
df <- padding(X, Y, fwd, bwd, pad.type = 'zero')
df <- padding(X, Y, fwd, bwd, fval, bval, pad.type = 'custom')

Arguments

X

An atomic numeric vector X signifying the X-axis of the dataset

Y

An atomic numeric vector Y signifying the X-axis of the dataset

fwd

A single whole number or integer specifying the no. of periods by which to increase the span of the dataset in the forward direction

bwd

A single whole number or integer specifying the no. of periods by which to increase the span of the dataset in the backward direction

pad.type

1. A single character which can take values of either, 'default', 'zero' or 'custom'.
2. The argument is set to 'default' by default.
3. When set to 'custom', the arguments *fval* and *bval* specifying forward and backward values are necessary.

fval

Defines the constant Y value of the function for the range of X greater than max(X)

bval

Defines the constant Y value of the function for the range of X less than min(X)

Details

1. When 'pad.type' is set to 'default', 'fval' is set to 'Y[X = max(X)]' and 'bval' is set to 'Y[X = min(X)]'.
2. When 'pad.type' is set to 'zero', then 'fval = bval = 0' is set for zero padding.
3. When 'pad.type' is set to 'custom', then fval and bval are needed as user inputs.

Value

1. The returned value is always a 2 column data frame.
2. The columns are named as 'X' and 'Y'.

Author(s)

Chitran Ghosal

Examples

X <- seq(0, 3, by = 0.01)
Y <- X^2
subplot(c(2,2))
df1 <- data.frame(X, Y)
plot(df1$X, df1$Y, type = 'l', main = 'without padding')
df2 <- padding(X, Y, fwd = 2, bwd = 3)
plot(df2$X, df2$Y, type = 'l', main = 'default')
df3 <- padding(X, Y, fwd = 1, bwd = 4, pad.type = 'zero')
plot(df3$X, df3$Y, type = 'l', main = 'zero')
df4 <- padding(X, Y, fwd = 0, bwd = 3, pad.type = 'custom', fval = NA, bval = 5 )
plot(df4$X, df4$Y, type = 'l', main = 'custom')
subplot(c(1,1))

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.