is.overlapping: Test for self-overlap

Description Usage Arguments Value Examples

View source: R/intervalaverage_functions.R

Description

Test whether a data.table contains intervals which partially or completely overlap with other intervals in different rows, possibly within groups

Usage

1
is.overlapping(x, interval_vars, group_vars = NULL, verbose = FALSE)

Arguments

x

A data.table with two columns defining closed intervals (see also interval_vars).

interval_vars

A length-2 character vector corresponding to column names of x which designate the closed (inclusive) starting and ending intervals. The column name specifying the lower-bound column must be specified first.

group_vars

NULL or a character vector corresponding to column names of x. overlap checks will occur within groups defined by the columns specified here.

verbose

prints additional information, default is FALSE

Value

length-1 logical vector. TRUE if there are overlaps, FALSE otherwise.

Examples

1
2
3
4
5
6
x <- data.table(start=c(1,2),end=c(3,4))
is.overlapping(x,c("start","end")) #the interval 1,3 overlaps with the interval 2,4
y <- data.table(start=c(1,3),end=c(2,4))
is.overlapping(y,c("start","end")) #the interval 1,2 doesn't overlap other intervals in y
z <- data.table(start=c(1,3,1,2),end=c(2,4,3,4),id=c(1,1,2,2))
is.overlapping(z,c("start","end"),"id")

intervalaverage documentation built on July 23, 2020, 5:09 p.m.