Learn R Programming

FitAR (version 1.94)

cts: Concantenate Time Series

Description

Creating a ts object by concatenating y onto x, where x is a ts object and y is a vector. If y is a ts object, it is simply converted to a vector and then concatenated on to x and the tsp attribute of y is ignored.

Usage

cts(x, y)

Arguments

x
a time series, a ts object
y
a vector which is concatenated on to x

Value

A time series which starts at start(x) and has length equal to length(x)+length(y).

Warning

Only two arguments are allowed, otherwise an error message will be given.

Details

If y is a ts object, it is first converted to a vector. Then the vector is concantenated on to the time series x. An error is given if x is not a ts object.

See Also

ts, start, window as.zooreg

Examples

Run this code
#Example 1
#Compare cts and c
#In the current version of R (2.6), they produce different results
z1<-window(lynx,end=1900)
z2<-window(lynx,start=1901)
z<-cts(z1,z2)
y<-c(z1,z2)

#See also Example 2 in predict.FitAR documentation

#Example 3. 
#Note tsp attribute of second argument is ignored but a warning is given if it is present
# and not aligned with first argument's attribute.
x <- ts(1:3)
z <- ts(6:7, start = 7)
cts(x,z) #warning given
y <- ts(4:5, start = 4)
cts(x,y) #no warning needed in this example.

Run the code above in your browser using DataLab