1.3.merge.data.pems: Merging data and pems objects

Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples

Description

Various pems.utils functions to merge data of different types.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#main function(s)

bindPEMS(x = NULL, y = NULL, ..., by = NULL)

#associated

cAlign(x = NULL, y = NULL, y.offset = 0, all = TRUE,
           suffixes = FALSE)

findLinearOffset(x = NULL, y = NULL, offset.range = NULL)

Arguments

x, y

(Required objects, typically pems objects, data.frames or vectors) For bindPEMS and cAlign, two objects to be bound together. For findLinearOffset, two objects to be aligned.

...

(Optional) Other arguments, currently passed on to cAlign and findLinearOffset.

by

(Optional numeric or character) When bindPEMS is supplied data.frames or pems objects as x and y and is asked to use findLinearOffset to find y.offset, which elements of x and y should be used? (If this is not supplied and required, the default assumption is the first element of each.)

y.offset

(Function or numeric) The number of rows to offset data in y by relative to data in x when combining them. For bindPEMS, this can be either a function that deteremines an offset, e.g. findLinearOffset, or a numeric value to be used directly as an offset. For cAlign, only a numeric is allowed.

all

(Currently disabled) Argument in revision.

suffixes

(Logical, or character) Any suffixes to be added to x and y. If one character terms is supplied this is used as a suffix for all names in y. If two character terms are supplied these are used as suffixes for all names in x and y, respectively. (The default FALSE does not add suffixes to either object.)

offset.range

(Numeric) For findLinearOffset, the 'lag window' to compare x and x across. By default, the function applies the widest possible window.

Details

bindPEMS is a column binding function that binds various objects types (e.g. pems objects, data.frames and vectors) and returns results as pems objects. It uses cAlign to bind associated data. Also, if requested, it uses findLinearOffset to handle alignments.

cAlign is a modification of the standard R column binding function cbind. cAlign binds data.frames (or vectors) subject to an applied offset, y.offset. The row displacement of the second data.frame relative to the first. Unlike cbind, cAlign does not require x and y to have the same number of columns. See NOte below.

findLinearOffset is a wrapper for the R function ccf. It is a lag function to find the best linear offset between two data series.

Value

bindPEMS returns supplied objects, x and y, as a single pems object, subject to requested alignment and naming modifications.

cAlign returns supplied objects, x and y, as a single data.frame, subject to requested alignment and naming modifications.

findLinearOffset returns the best fit offset for y relative to x.

Warning

No warnings

Note

cAlign generates offsets and pads out data.frames of different column lengths by the addition of NAs. So, data.frames do not need to be the same column length to be bound, and alignment is subject y.offset, a numeric giving the starting row for y relative to x. data.frame names are handled using make.names, by the suffixes argument to manage names directly.

Author(s)

Karl Ropkins

References

References in preparation.

See Also

See cbind for standard column binding in R.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
###########
##example 1 
###########

#some data
temp <- rnorm(500)

#get two offset ranges

x <- temp[25:300]
y <- temp[10:200]

plot(x, type="l"); lines(y, col="blue", lty=2)

#estimated offset

findLinearOffset(x,y)
#[1] -15

#applying linear offset

ans <- cAlign(x,y, findLinearOffset(x,y))

plot(ans$x, type="l"); lines(ans$y, col="blue", lty=2)

pems documentation built on May 2, 2019, 5:20 p.m.