cbind.ts: Combine Time Series Objects

cbind.tsR Documentation

Combine Time Series Objects

Description

A replacement for the S3 method registered by package stats for generic function cbind and class ts. It sets column names following the rules employed by the internal default method for cbind. It exists to allow users to work around \Sexpr[results=rd]{tools:::Rd_expr_PR(18583)}, which shows that the method in package stats employs different and rather inconsistent rules. This function must be called directly, as it is not registered as a method for cbind.

Usage

## S3 method for class 'ts'
cbind(..., deparse.level = 1)

Arguments

...

vectors (including matrices), at least one inheriting from class ts.

deparse.level

an integer (0, 1, or 2) controlling how column names are determined for untagged arguments that are not matrices, following the internal default method for cbind.

Value

A “multiple time series” object, inheriting from class mts.

Examples


n <- 3L
x <- matrix(0, n, n, dimnames = list(NULL, LETTERS[seq_len(n)]))
y <- seq_len(n)
tsx <- ts(x)
tsy <- ts(y)
`~` <- identity
for (k in 0L:2L) {
	cat(sprintf("k = %d:\n\n\n", k))
	withAutoprint({
	try(colnames(cbind   (   x,    y, deparse.level = k)))
	try(colnames(cbind   ( tsx,  tsy, deparse.level = k)))
	try(colnames(cbind.ts( tsx,  tsy, deparse.level = k)))
	try(colnames(cbind   (~  x, ~  y, deparse.level = k)))
	try(colnames(cbind   (~tsx, ~tsy, deparse.level = k)))
	try(colnames(cbind.ts(~tsx, ~tsy, deparse.level = k)))
	})
	cat("\n\n")
}
rm(`~`)

davidearn/fastbeta documentation built on July 4, 2025, 6:28 p.m.