overlaps: Overlapping number line objects

View source: R/overlap.R

overlapsR Documentation

Overlapping number line objects

Description

Identify overlapping number_line objects

Usage

overlaps(x, y, methods = 8)

overlap(x, y)

none(x, y)

exact(x, y)

across(x, y)

x_across_y(x, y)

y_across_x(x, y)

chain(x, y)

x_chain_y(x, y)

y_chain_x(x, y)

aligns_start(x, y)

x_aligns_start_y(x, y)

y_aligns_start_x(x, y)

aligns_end(x, y)

x_aligns_end_y(x, y)

y_aligns_end_x(x, y)

inbetween(x, y)

x_inbetween_y(x, y)

y_inbetween_x(x, y)

overlap_method(x, y)

include_overlap_method(methods)

exclude_overlap_method(methods)

overlap_method_codes(methods)

overlap_method_names(methods)

Arguments

x

[number_line]

y

[number_line]

methods

[charater|integer]. Type of overlap. See as.data.frame(diyar::overlap_methods$options) for options.

Details

There are 6 mutually exclusive types of overlap;

  • exact() - identical start_point and end_point points.

  • inbetween() - Both start_point and end_point of one number_line object are within the start_point and end_point of another.

  • across() - Only the start_point or end_point of one number_line object is in between the start_point and end_point of another.

  • chain() - end_point of one number_line object is identical to the start_point of another.

  • aligns_start() - identical start_point only.

  • aligns_end() - identical end_point only.

Except exact(), each type of overlap has two variations;

  • x_`method`_y() - number_line-x starts before number_line-y.

  • y_`method`_x() - number_line-y starts before number_line-x.

There are two mutually inclusive types of overlap;

  • overlap() - a convenient option to select "ANY" and "ALL" type of overlap.

  • none() - a convenient option to select "NO" type of overlap.

Selecting multiple types of overlap;

  • overlaps() - select specific type(s) of overlap.

  • overlap_method() - return the type of overlap for a pair of number_line objects.

  • overlap_method_codes() - return the corresponding overlap method code for a specific type(s) of overlap.

  • overlap_method_names() - return the corresponding type(s) of overlap for a specific overlap code.

  • include_overlap_method() - return a character(1) value for specified type(s) of overlap.

  • exclude_overlap_method() - return a character(1) value for all type(s) of overlap except those specified.

Value

logical; character

See Also

number_line; set_operations

Examples

a <- number_line(-100, 100)
g <- number_line(100, 100)
overlaps(a, g)

# It's neither an "exact" or "chain"-overlap
overlaps(a, g, methods = "exact|chain")

# It's an "aligns_end"-overlap
overlap_method(a, g)
overlaps(a, g, methods = "exact|chain|x_aligns_end_y")

# Corresponding overlap code
overlap_method_codes("exact|chain|x_aligns_end_y")
include_overlap_method(c("exact", "chain", "x_aligns_end_y"))

# Corresponding overlap name
overlap_method_names(overlap_method_codes("exact|chain|x_aligns_end_y"))

# Every other type overlap
exclude_overlap_method(c("exact", "chain", "x_aligns_end_y"))
overlap_method_names(exclude_overlap_method(c("exact", "chain", "x_aligns_end_y")))

# All the above is based on tests for each specific type of overlap as seen below
none(a, g)
exact(a, g)
across(a, g)
x_across_y(a, g)
y_across_x(a, g)
chain(a, g)
x_chain_y(a, g)
y_chain_x(a, g)
inbetween(a, g)
x_inbetween_y(a, g)
y_inbetween_x(a, g)
aligns_start(a, g)
x_aligns_start_y(a, g)
y_aligns_start_x(a, g)
aligns_end(a, g)
x_aligns_end_y(a, g)
y_aligns_end_x(a, g)


OlisaNsonwu/diyar documentation built on April 22, 2024, 6:27 p.m.