Create a list container and loop through the IDs
activity_in_use <- list() for (i in 1:length(active_people)) { activity_in_use[[i]] <- filter(d_activity, Id %in% i) }
Put the list together
dfout <- Reduce(rbind, activity_in_use)