align_idx {dtts}R Documentation

Get the index of the alignment of one vector onto another

Description

align_idx returns the index of the alignment of x on y

Usage

align_idx(x, y, start, end, ...)

## S4 method for signature 'nanotime,nanotime,nanoduration,nanoduration'
align_idx(
  x,
  y,
  start,
  end,
  sopen = FALSE,
  eopen = TRUE,
  bypass_x_check = FALSE,
  bypass_y_check = FALSE
)

## S4 method for signature 'nanotime,nanotime,missing,missing'
align_idx(
  x,
  y,
  start,
  end,
  sopen = FALSE,
  eopen = TRUE,
  bypass_x_check = FALSE,
  bypass_y_check = FALSE
)

## S4 method for signature 'nanotime,nanotime,missing,nanoduration'
align_idx(
  x,
  y,
  start,
  end,
  sopen = FALSE,
  eopen = TRUE,
  bypass_x_check = FALSE,
  bypass_y_check = FALSE
)

## S4 method for signature 'nanotime,nanotime,nanoduration,missing'
align_idx(
  x,
  y,
  start,
  end,
  sopen = FALSE,
  eopen = TRUE,
  bypass_x_check = FALSE,
  bypass_y_check = FALSE
)

## S4 method for signature 'nanotime,nanotime,nanoperiod,nanoperiod'
align_idx(
  x,
  y,
  start = as.nanoperiod(0),
  end = as.nanoperiod(0),
  sopen = FALSE,
  eopen = TRUE,
  tz,
  bypass_x_check = FALSE,
  bypass_y_check = FALSE
)

## S4 method for signature 'nanotime,nanotime,missing,nanoperiod'
align_idx(
  x,
  y,
  start = as.nanoperiod(0),
  end = as.nanoperiod(0),
  sopen = FALSE,
  eopen = TRUE,
  tz,
  bypass_x_check = FALSE,
  bypass_y_check = FALSE
)

## S4 method for signature 'nanotime,nanotime,nanoperiod,missing'
align_idx(
  x,
  y,
  start = as.nanoperiod(0),
  end = as.nanoperiod(0),
  sopen = FALSE,
  eopen = TRUE,
  tz,
  bypass_x_check = FALSE,
  bypass_y_check = FALSE
)

Arguments

x

the nanotime vector to align from

y

the nanotime vector to align to

start

scalar or vector of same length as y of type nanoduration or nanoperiod; start is added to each element in y and it then defines the starting point of the interval under consideration for the alignment on that element of y

end

scalar or vector of same length as y of type nanoduration or nanoperiod; start is added to each element in y and it then defines the ending point of the interval under consideration for the alignment on that element of y

...

further arguments passed to or from methods.

sopen

boolean scalar or vector of same lengths as y that indicates if the start of the interval is open or closed. Defaults to FALSE.

eopen

boolean scalar or vector of same lengths as y that indicates if the end of the interval is open or closed. Defaults to TRUE.

bypass_x_check

logical indicating if the sorting of x should be bypassed. This can provide a marginal speedup, but should be used carefully.

bypass_y_check

logical indicating if the sorting of y should be bypassed. This can provide a marginal speedup, but should be used carefully.

tz

scalar or vector of same length as y of type character. Only used when the type of start and end is nanoperiod. It defines the time zone for the definition of the interval.

Details

In order to perform the alignment, intervals are created around each elements in y using start and end. For each such interval, the closest element in x is chosen. If no element in x falls in the interval, then NaN is returned.

When only x and y are specified, the default is to close the intervals so that the alignment simply picks up equal points. Note that it is possible to specify meaningless intervals, for instance with a start that is beyond end. In this case, the alignment will simply return NA for each element in y. In principle, the start and end are chosen to define an interval is the past, or around the points in y, but if they are both positive, they can define intervals in the future.

Value

a vector of indices of the same length as y; this vector indexes into x and represent the closest point of x that is in the interval defined around each point in y

Examples

## Not run: 
align_idx(nanotime(c(10:14, 17:19)), nanotime(11:20))
## [1]  2  3  4  5  NA NA  6  7  8  NA

## End(Not run)

[Package dtts version 0.1.3 Index]