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
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.
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.
Note
The package zoo may also be used to concatenate time series, as in this example,
x <- ts(1:3)
y <- ts(4:5, start = 4)
z <- ts(6:7, start = 7)
library("zoo")
as.ts(c(as.zooreg(x), y, z))
Author(s)
A.I. McLeod
See Also
ts,
start,
windowas.zooreg
Examples
#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.
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(FitAR)
Loading required package: lattice
Loading required package: leaps
Loading required package: ltsa
Loading required package: bestglm
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/FitAR/cts.Rd_%03d_medium.png", width=480, height=480)
> ### Name: cts
> ### Title: Concantenate Time Series
> ### Aliases: cts
> ### Keywords: ts
>
> ### ** Examples
>
> #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
Time Series:
Start = 1
End = 5
Frequency = 1
[1] 1 2 3 6 7
Warning message:
In cts(x, z) : y coerced to vector and tsp attribute ignored
> y <- ts(4:5, start = 4)
> cts(x,y) #no warning needed in this example.
Time Series:
Start = 1
End = 5
Frequency = 1
[1] 1 2 3 4 5
>
>
>
>
>
>
> dev.off()
null device
1
>