Trim the largest vector by cutting it, or filling it with NA. Fill the shortest vector with padding.

ts_trimfill(
  x,
  y,
  action = c("fill", "trim.cut", "trim.NA")[1],
  type = c("end", "center", "front")[1],
  padding = 0,
  silent = TRUE
)

Arguments

x

A numeric vector

y

A numeric vector

action

Use "fill" to fill the shortest vector with padding (default); "trim.cut" to trim the longest vector to the length of the shortest; "trim.NA" to fill the longest vector with NA. This is a shortcut for running action = "trim.cut" with padding=NA, which can be useful if one wants to match the shortest series, but preserve the original length of largest vector.

type

Should trimming or filling take place at the "end" (default), or "front" of the vector? The option "center" will try to distribute trimming by NA or filling by padding evenly across the front and end of the vector.

padding

A value to use for padding (default = 0)

silent

Run silent-ish

Value

A list with two vectors of equal length.

Author

Fred Hasselman