Learn R Programming

fastbeta (version 0.5.1)

cbind.ts: 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 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 ts
cbind(..., deparse.level = 1)

Value

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

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.

Examples

Run this code
# \dontshow{
## for R_DEFAULT_PACKAGES=NULL
library(stats, pos = "package:base", verbose = FALSE)
# }
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(`~`)

Run the code above in your browser using DataLab