I have a data with 100 patients and each patient has values from 7 days (1 to 7). How can I select only patients according another variable only in day 1?
df <
When using dplyr:
dplyr
library(dplyr) df %>% group_by(id) %>% filter(day == 1 & RRT == 0) %>% select(id)
or base R:
df[df$day == 1 & df$RRT ==0,"id"]