Filtering data in R, in a for loop

Solution 1:

Use %in% instead of ==, thus we can remove the | along with multiple statements

dplyr::filter(d_activity, Id %in% active_people)