diffFill: An extension on 'diff' from base R that fills blank space...

View source: R/diffFill.R

diffFillR Documentation

An extension on 'diff' from base R that fills blank space with NA

Description

An extension on 'diff' from base R that fills blank space with NA

Usage

diffFill(x, lag = 1, differences = 1, name = NULL, ...)

Arguments

x

a numeric vector OR matrix containing the values to be differenced

lag

(Optional) an integer indicating which lag to use. If 'x' is a vector, 'lag' can also be a vector. Defaults to 1

differences

(Optional) an integer indicating the order of the difference. If 'x' is a vector, 'differences' can also be a vector. Defaults to 1

name

(Optional) A name to be used in the lagged data.frame. Defaults to the name of the variable passed to 'x'. If that is not possible, 'name' will default to "X".

...

(Optional) further arguments to be passed to or from methods

Value

Returns a vector of the same length as the input, otherwise behaves the same as diff. If the input is a matrix, it returns a matrix.

Examples

# Creating dummy data
# for 1 lag and 2 differences
diffFill(rnorm(10), 1, 2)

guslipkin/dewey documentation built on March 16, 2023, 8:19 a.m.