As is, filtering by an interval returns children who are entirely outside that interval (eg get_participants(age = c(4,20)) returns participant 2 with an age range of min_age = 146.72581 and max_age = 146.75866)
If we want any child who's interval overlaps with the input interval, this logic covers all the bases:
(min_age <= days_1 & max_age >= days_2)| (min_age >= days_1 & max_age <= days_2)| (min_age <= days_1 & max_age >= days_1)| (min_age <= days_2 & max_age >= days_2)
As is, filtering by an interval returns children who are entirely outside that interval (eg
get_participants(age = c(4,20))
returns participant 2 with an age range ofmin_age = 146.72581
andmax_age = 146.75866
)If we want any child who's interval overlaps with the input interval, this logic covers all the bases:
(min_age <= days_1 & max_age >= days_2)| (min_age >= days_1 & max_age <= days_2)| (min_age <= days_1 & max_age >= days_1)| (min_age <= days_2 & max_age >= days_2)
If we want only children who's age interval is strictly within the input interval,
(min_age >= days_1 & max_age <= days_2)
works, too. https://github.com/langcog/childesr/blob/f3de7028bb41af1290dfd9344b440040c9271022/R/childesr.R#L280