allen-relation-detect-pairwise {ivs}R Documentation

Pairwise detect relations from Allen's Interval Algebra

Description

iv_pairwise_relates() is similar to iv_pairwise_overlaps(), but it detects a specific set of relations developed by James Allen in the paper: Maintaining Knowledge about Temporal Intervals.

Usage

iv_pairwise_relates(x, y, ..., type)

Arguments

x, y

⁠[iv]⁠

A pair of interval vectors.

These will be recycled against each other and cast to the same type.

...

These dots are for future extensions and must be empty.

type

⁠[character(1)]⁠

The type of relationship to find. See the Allen's Interval Algebra section for a complete description of each type. One of:

  • "precedes"

  • "preceded-by"

  • "meets"

  • "met-by"

  • "overlaps"

  • "overlapped-by"

  • "starts"

  • "started-by"

  • "during"

  • "contains"

  • "finishes"

  • "finished-by"

  • "equals"

Value

A logical vector the same size as the common size of x and y.

Allen's Interval Algebra

The interval algebra developed by James Allen serves as a basis and inspiration for iv_locate_overlaps(), iv_locate_precedes(), and iv_locate_follows(). The original algebra is composed of 13 relations which have the following properties:

Take the notation that x and y represent two intervals. Now assume that x can be represented as ⁠[x_s, x_e)⁠, where x_s is the start of the interval and x_e is the end of it. Additionally, assume that x_s < x_e. With this notation, the 13 relations are as follows:

Note that when missing = "equals", missing intervals will only match the type = "equals" relation. This ensures that the distinct property of the algebra is maintained.

Connection to other functions

Note that some of the above relations are fairly restrictive. For example, "overlaps" only detects cases where x straddles y_s. It does not consider the case where x and y are equal to be an overlap (as this is "equals") nor does it consider when x straddles y_e to be an overlap (as this is "overlapped-by"). This makes the relations extremely useful from a theoretical perspective, because they can be combined without fear of duplicating relations, but they don't match our typical expectations for what an "overlap" is.

iv_locate_overlaps(), iv_locate_precedes(), and iv_locate_follows() use more intuitive types that aren't distinct, but typically match your expectations better. They can each be expressed in terms of Allen's relations:

See Also

Locating relationships

Locating relations from Allen's Interval Algebra

Detecting relations from Allen's Interval Algebra

Examples

x <- iv_pairs(c(1, 3), c(3, 5))
y <- iv_pairs(c(3, 4), c(6, 7))

# `"precedes"` is strict, and doesn't let the endpoints match
iv_pairwise_relates(x, y, type = "precedes")

# Since that is what `"meets"` represents
iv_pairwise_relates(x, y, type = "meets")

# `"during"` only matches when `x` is completely contained in `y`, and
# doesn't allow any endpoints to match
x <- iv_pairs(c(1, 3), c(4, 5), c(8, 9))
y <- iv_pairs(c(1, 4), c(3, 8), c(8, 9))

iv_pairwise_relates(x, y, type = "during")

[Package ivs version 0.2.0 Index]