tsmerge: Merging for Time Series and Signals

Description Usage Arguments Value See Also Examples

Description

Merges time series or signal objects, making a new object with all the columns of the input objects, and some or all of the rows, depending on how their positions match.

Usage

1
2
3
seriesMerge(x1, x2, ..., pos=positions(x1), how,
        error.how, localzone=FALSE, matchtol=0,  
        suffixes)

Arguments

x1

the first object to be merged.

x2

the second object to be merged.

...

the other objects to be merged.

pos

the positions to align to, or "union" to make a union of all input positions. (The default argument values give an intersection of all the positions.)

how

after the positions to align to are determined, how determines how to treat positions that are missing from the various input objects.

Can be one of the following:

"NA" Inserts a row of NA.
"drop" Drops that position entirely.
"nearest" Uses the row with the nearest position.
"before" Uses the data from the row whose position is just before the unmatched position.
"after" Uses the data from the row whose position is just after the unmatched position.
"interp" Interpolates linearly between "before" and "after".

The default is "drop" unless pos="union", in which case "drop" makes no sense and the default is "NA".

error.how

specifies what to do in the event of an out of bounds error, which can occur when how is "before", "after", or "interp".

Can be one of the following:

"NA" Inserts a row of NA
"drop" Drops that position entirely
"nearest" Uses the row with the nearest position.

The default is "drop" unless pos="union", in which case "drop" makes no sense and the default is "NA".

localzone

if TRUE (that is, all input positions must be calendar-based), merge by matching/interpolating with all positions in their local time zones, instead of with the absolute GMT times.

matchtol

the tolerance for matching positions. Positions that match within matchtol do not invoke how argument methods.

suffixes

the suffixes to append to the column names that are duplicated between the various input data objects. The default value is paste(".", 1:nargs, sep = ""), where nargs is the total number of data arguments.

Value

returns a new series object containing all the columns of all the inputs, and all the rows of all the inputs, according to the alignment methods described above.

See Also

timeSeries, signalSeries, positions, align, merge.

Examples

1
2
3
4
5
6
7
8
a <- signalSeries(pos=1:10, data=data.frame(a = 11:20, b = 5 * (1:10))) 
b <- signalSeries(pos=5:14, data=data.frame(a = 11:20, b = 5 * (1:10))) 
seriesMerge(a, b) 
a <- timeSeries(pos=as(1:10, "timeDate"), 
		data=data.frame(a = 11:20, b = 5 * (1:10))) 
b <- timeSeries(pos=as(5:14, "timeDate"), 
	        data=data.frame(a = 11:20, b = 5 * (1:10))) 
seriesMerge(a, b, pos="union") 

Example output

Loading required package: splusTimeDate

Attaching package:splusTimeDateThe following objects are masked frompackage:base:

    months, quarters, sort.list, weekdays

 Positions a.1 b.1 a.2 b.2
 5         15  25  11   5 
 6         16  30  12  10 
 7         17  35  13  15 
 8         18  40  14  20 
 9         19  45  15  25 
 10        20  50  16  30 
 Positions  a.1 b.1 a.2 b.2
 01/02/1960 11   5  NA  NA 
 01/03/1960 12  10  NA  NA 
 01/04/1960 13  15  NA  NA 
 01/05/1960 14  20  NA  NA 
 01/06/1960 15  25  11   5 
 01/07/1960 16  30  12  10 
 01/08/1960 17  35  13  15 
 01/09/1960 18  40  14  20 
 01/10/1960 19  45  15  25 
 01/11/1960 20  50  16  30 
 01/12/1960 NA  NA  17  35 
 01/13/1960 NA  NA  18  40 
 01/14/1960 NA  NA  19  45 
 01/15/1960 NA  NA  20  50 

splusTimeSeries documentation built on April 30, 2021, 5:09 p.m.