tsutils (version 0.9.4)

leadtrail: Remove leading/training zeros/NAs

Description

Remove leading or trailing zeros or NAs from a vector.

Usage

leadtrail(
  x,
  rm = c("zeros", "na"),
  lead = c(TRUE, FALSE),
  trail = c(TRUE, FALSE)
)

Value

Resulting vector.

Arguments

x

vector of values to check.

rm

what to remove, can be "zeros" or "na".

lead

If TRUE, then leading values are removed.

trail

If TRUE, then trailing values are removed.

Author

Nikolaos Kourentzes, nikolaos@kourentzes.com.

Examples

Run this code
x <- c(rep(0,5),rnorm(100),rep(0,5))
leadtrail(x)

Run the code above in your browser using DataLab