Skip to contents

Merges several object types with "timeSeries" objects. The number of rows must match.

Usage

merge(x, y, ...)

Arguments

x,y

objects to merge, at least one of class "timeSeries".

...

further objects to merge.

Value

a "timeSeries" object

Methods

signature(x = "timeSeries", y = "missing")

signature(x = "timeSeries", y = "ANY")

signature(x = "timeSeries", y = "matrix")

signature(x = "timeSeries", y = "numeric")

signature(x = "timeSeries", y = "timeSeries")

signature(x = "ANY", y = "ANY")

signature(x = "ANY", y = "timeSeries")

signature(x = "matrix", y = "timeSeries")

signature(x = "numeric", y = "timeSeries")

See also

Examples

## Load Series -
   x <- MSFT[1:12, ]

## Merge 'timeSeries' with missing Object -
   merge(x)
#> GMT 
#>               Open    High     Low   Close   Volume
#> 2000-09-27 63.4375 63.5625 59.8125 60.6250 53077800
#> 2000-09-28 60.8125 61.8750 60.6250 61.3125 26180200
#> 2000-09-29 61.0000 61.3125 58.6250 60.3125 37026800
#> 2000-10-02 60.5000 60.8125 58.2500 59.1250 29281200
#> 2000-10-03 59.5625 59.8125 56.5000 56.5625 42687000
#> 2000-10-04 56.3750 56.5625 54.5000 55.4375 68226700
#> 2000-10-05 55.5000 57.2500 55.2500 55.3750 40549700
#> 2000-10-06 55.8125 56.7500 54.7500 55.5625 30897000
#> 2000-10-09 55.6250 55.7500 53.0000 54.1875 29161800
#> 2000-10-10 53.9375 55.5625 53.8125 54.5625 31033100
#> 2000-10-11 54.0000 56.9375 54.0000 55.7500 50602900
#> 2000-10-12 56.3125 56.8750 53.8125 54.3750 45109800

set.seed(1234)
## Merge 'timeSeries' with numeric Object -
   y <- rnorm(12)
   class(y)
#> [1] "numeric"
   merge(x, y)
#> GMT 
#>               Open    High     Low   Close   Volume          x
#> 2000-09-27 63.4375 63.5625 59.8125 60.6250 53077800 -1.2070657
#> 2000-09-28 60.8125 61.8750 60.6250 61.3125 26180200  0.2774292
#> 2000-09-29 61.0000 61.3125 58.6250 60.3125 37026800  1.0844412
#> 2000-10-02 60.5000 60.8125 58.2500 59.1250 29281200 -2.3456977
#> 2000-10-03 59.5625 59.8125 56.5000 56.5625 42687000  0.4291247
#> 2000-10-04 56.3750 56.5625 54.5000 55.4375 68226700  0.5060559
#> 2000-10-05 55.5000 57.2500 55.2500 55.3750 40549700 -0.5747400
#> 2000-10-06 55.8125 56.7500 54.7500 55.5625 30897000 -0.5466319
#> 2000-10-09 55.6250 55.7500 53.0000 54.1875 29161800 -0.5644520
#> 2000-10-10 53.9375 55.5625 53.8125 54.5625 31033100 -0.8900378
#> 2000-10-11 54.0000 56.9375 54.0000 55.7500 50602900 -0.4771927
#> 2000-10-12 56.3125 56.8750 53.8125 54.3750 45109800 -0.9983864

## Merge 'timeSeries' with matrix Object -
   y <- matrix(rnorm(24), ncol=2)
   class(y)
#> [1] "matrix" "array" 
   merge(x, y)
#> GMT 
#>               Open    High     Low   Close   Volume         y.1        y.2
#> 2000-09-27 63.4375 63.5625 59.8125 60.6250 53077800 -0.77625389 -0.6937202
#> 2000-09-28 60.8125 61.8750 60.6250 61.3125 26180200  0.06445882 -1.4482049
#> 2000-09-29 61.0000 61.3125 58.6250 60.3125 37026800  0.95949406  0.5747557
#> 2000-10-02 60.5000 60.8125 58.2500 59.1250 29281200 -0.11028549 -1.0236557
#> 2000-10-03 59.5625 59.8125 56.5000 56.5625 42687000 -0.51100951 -0.0151383
#> 2000-10-04 56.3750 56.5625 54.5000 55.4375 68226700 -0.91119542 -0.9359486
#> 2000-10-05 55.5000 57.2500 55.2500 55.3750 40549700 -0.83717168  1.1022975
#> 2000-10-06 55.8125 56.7500 54.7500 55.5625 30897000  2.41583518 -0.4755931
#> 2000-10-09 55.6250 55.7500 53.0000 54.1875 29161800  0.13408822 -0.7094400
#> 2000-10-10 53.9375 55.5625 53.8125 54.5625 31033100 -0.49068590 -0.5012581
#> 2000-10-11 54.0000 56.9375 54.0000 55.7500 50602900 -0.44054787 -1.6290935
#> 2000-10-12 56.3125 56.8750 53.8125 54.3750 45109800  0.45958944 -1.1676193

## Merge 'timeSeries' with matrix Object -
   y <- timeSeries(data=rnorm(12), charvec=time(x))
   class(y)
#> [1] "timeSeries"
#> attr(,"package")
#> [1] "timeSeries"
   merge(x, y)
#> GMT 
#>               Open    High     Low   Close   Volume       TS.1
#> 2000-09-27 63.4375 63.5625 59.8125 60.6250 53077800 -2.1800396
#> 2000-09-28 60.8125 61.8750 60.6250 61.3125 26180200 -1.3409932
#> 2000-09-29 61.0000 61.3125 58.6250 60.3125 37026800 -0.2942939
#> 2000-10-02 60.5000 60.8125 58.2500 59.1250 29281200 -0.4658975
#> 2000-10-03 59.5625 59.8125 56.5000 56.5625 42687000  1.4494963
#> 2000-10-04 56.3750 56.5625 54.5000 55.4375 68226700 -1.0686427
#> 2000-10-05 55.5000 57.2500 55.2500 55.3750 40549700 -0.8553646
#> 2000-10-06 55.8125 56.7500 54.7500 55.5625 30897000 -0.2806230
#> 2000-10-09 55.6250 55.7500 53.0000 54.1875 29161800 -0.9943401
#> 2000-10-10 53.9375 55.5625 53.8125 54.5625 31033100 -0.9685143
#> 2000-10-11 54.0000 56.9375 54.0000 55.7500 50602900 -1.1073182
#> 2000-10-12 56.3125 56.8750 53.8125 54.3750 45109800 -1.2519859