Skip to contents

Pad a `ts` with zeros

Usage

pad(x, tstart, tend, at = 0)

Arguments

x

A `ts` object.

tstart

A numeric. Start time of output.

tend

A numeric. End time of output.

at

A numeric. Starting time to inject original `x`, no matter `x` has its own time stamps.

Value

A padded `ts` object.

Examples

if (FALSE) { # \dontrun{
# Original signal from t = 0 with 0.1 sec spacing
x <- ts(1:5, deltat = 0.1)

# Pad x into a 1-second series starting at t = 1.3
padded <- pad(x, tstart = 1, tend = 2, at = 1.3)
# shows time indices from 1.0 to 2.0
time(padded)
# shows inserted values at 1.3, 1.4, ..., 1.7
padded

# If x has time of -2, -1, 0, 1, 2,
x <- ts(1:5, start = -2)
# And pad with at = 0,
padded <- pad(x, tstart = -10, tend = 10, at = 0)
# x will start from 0 time not -2
} # }