Skip to contents

Correlation based (linear) alignment, row offsetting second of two vectors or data.frames based on best fit as estimated by correlation coefficient.

Usage

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

Arguments

x

First vector or data.frame, to be aligned and merged with.

y

Second vector or data.frame, to align and merge with x.

by

If x or y are data.frames, the names of the columns that cor_align should align with.

...

Other arguments:

min.overlap

By default, cor_align compares correlations for lags with x/y overlaps of 2000 rows or 20% if smaller. Other minimum (row number) overlaps can be set using the extra argument min.overlap.

output

The default cor_align output is c("plot", "summary", "ans"). output options include: "ans", "plot", "summary" and "alignment". Multiple outputs are allowed, but only the last is captured by return. alignment is a special object class which may be helpful to those looking at alignments in more detail.

Value

By default, cor_align returns x and y

as an aligned data.frame. It also provides a lag correlation profile (plot) and alignment report. See above about modifying outputs.

Note

cor_align is based on cAlign function in earlier version of pems.utils. It works with vectors, data.frames and other objects that can be converted to data.frame with as.data.frame(), and uses Rcpp to run C++ code.

Author

Karl Ropkins