matchIndices: matchIndices

Description Usage Arguments Details Value Examples

View source: R/matchIndices.R

Description

Matches two vectors with different lengths based on their maximum value.

Usage

1
matchIndices(x, y, z)

Arguments

x

Target numeric vector.

y

Reference numeric vector.

z

A numeric element.

Details

Uses Dynamic Time Wrapping (DTW) to match x and y. z determines the buffer size - expressed in number of data points - used to search for matching records.

Value

A list with selected indices for x and y.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{

x <- c(2200, 4500, 4600, 6400, 1600) # target
y <- c(1100, 1150, 1200, 6400, 1600) # reference

i <- matchIndices(x, y, 1) # find best match

# plot x (blue), and selected y (red)
plot(1:5, replicate(5,0), ylim=c(0,10000), type="l") 
lines(i$x, x[i$x], type="l", col="blue")
lines(i$y, y[i$y], type="l", col="red")

}

RRemelgado/CAWaR documentation built on June 7, 2020, 10:27 p.m.