Learn R Programming

timeSeries (version 4041.111)

cbind: Bind 'timeSeries' objects by column or row

Description

Binds "timeSeries" objects either by column or by row.

Usage

# S3 method for timeSeries
cbind(..., deparse.level = 1)
# S3 method for timeSeries
rbind(..., deparse.level = 1)

# S4 method for timeSeries,ANY cbind2(x, y) ## other methods for 'cbind2' with the same arguments, see Details

# S4 method for timeSeries,ANY rbind2(x, y) ## other methods for 'rbind2' with the same arguments, see Details

Value

an object of class "timeSeries"

Arguments

x, y

objects, at least one of whom is of class "timeSeries".

...

further arguments to bind.

deparse.level

see the documentation of base::cbind.

Details

These functions bind the objects by row rXXX or column (cXXX.

cbind and rbind are S3 generics, so the "timeSeries" methods describe here are called only when the first argument is "timeSeries".

cbind2 and rbind2 are S4 generics which dispatch on the first two arguments. The "timeSeries" methods for these are invoked whenever at least one of the first two arguments is of class "timeSeries".

All functions can be called with more than two arguments. After the first two are merged, the result is merged with the third, and so on.

See Also

merge for another way to merge "timeSeries" object column-wise.

rbind and cbind from base R,

rbind2 and cbind2 from package "methods",

Examples

Run this code
## Load Microsoft Data Set -
   x <- MSFT[1:12, ]
   x

## Bind Columnwise -
   X <- cbind(x[, "Open"], returns(x[, "Open"]))
   colnames(X) <- c("Open", "Return")
   X

## Bind Rowwise - 
   Y <- rbind(x[1:3, "Open"], x[10:12, "Open"])
   Y

Run the code above in your browser using DataLab