langcog/childesr

get_participants age filtering

Closed this issue · 0 comments

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)

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.

participants %<>% dplyr::filter(max_age >= days_1 | min_age <= days_2)