Learn R Programming

networkDynamic (version 0.11.4)

spells.overlap: Functions to compare and search spell intervals

Description

spells.overlap checks if two spells overlap at all, spells.hit searches a spell matrix for an overlapping spell

Usage

spells.overlap(s1, s2)

spells.hit(needle, haystack)

search.spell(needle, haystack)

Value

spells.overlap returns a boolean indicating if the two spells overlap or not.

spells.hit returns the integer row index of the first (earliest) spell in haystack that overlaps with needle, or -1 if no overlaps are found

search.spell returns a vector containing the row indices of spells in haystack that overlap with needle, or numeric(0) if none found

Arguments

s1

First spell for in the comparison, must be a two-element numeric vector in the form [onset,terminus]

s2

Second spell for in the comparison, must be a two-element numeric vector in the form [onset,terminus]

needle

The query spell used in the search, must be a two-element numeric vector in the form [onset,terminus]

haystack

The spell matrix to be searched by needle. Must be two column numeric matrix meeting the order specifications of a spell matrix. See activity.attribute

Author

skyebend@uw.edu

Details

Spell overlap is defined as true if one of the following conditions sets is met, otherwise false:

onset1 >= onset2 AND onset1 < terminus2

terminus1 > onset2 AND terminus1 <= terminus2

onset1 <= onset2 AND terminus1 >= terminus2

See Also

See Also activity.attribute

Examples

Run this code
a <- c(1,3)
b <- c(2,5.5)
c <- c(-1,10)
d <- c(4,4)
spells.overlap(a,b)
spells.overlap(b,c)
spells.overlap(a,d)

spellmat <- rbind(c(0,1), c(1,2), c(2,3))
spells.hit(c(1,2),spellmat)

Run the code above in your browser using DataLab