Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

spell_comparisons

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)

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

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

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

Author(s)

skyebend@uw.edu

See Also

Examples

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)

networkDynamic

Dynamic Extensions for Network Objects

v0.10.1
GPL-3
Authors
Carter T. Butts [aut], Ayn Leslie-Cook [aut], Pavel N. Krivitsky [aut], Skye Bender-deMoll [aut, cre], Zack Almquist [ctb], David R. Hunter [ctb], Li Wang [ctb], Kirk Li [ctb], Steven M. Goodreau [ctb], Jeffrey Horner [ctb], Martina Morris [ctb]
Initial release
2020-01-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.