Reputation: 453
I have written a loop that works but is super slow because it iterates through users that don't have both pre- and post- data in an intervention study. For my purposes, I would only like to include users who have data before and after a certain timestamp (of which the timestamp is different for each user).
Essentially, I would like a loop that says:
if (user_file$date does not have values BOTH before AND after user_file$timestamp) {
next
}
Many thanks in advance for any assistance.
Upvotes: 0
Views: 25
Reputation: 399
You'll want to do some preprocessing of your data: For each user compute their earliest and latest data entry dates. Then in your loop, you can just check if the user's earliest date is before their corresponding timestamp and if their latest date is after their corresponding timestamp.
Upvotes: 1