0

I only need the first survey of a repeating census with the same individuals, so I choose the first time the person gave the interview, which works, but I get a new object without all other variables of the inital df. How can I keep all columns?

df$var1 <- df%>%strptime(var1, "%Y-%m-%d")
survey_1 <- df%>% group_by(per)%>% summarise(var1 = min(var1))
Ronak Shah
  • 355,584
  • 18
  • 123
  • 178

1 Answers1

0

Change summarize to filter

df %>% group_by(per) %>% filter(var1 == min(var1))
Vinícius Félix
  • 4,501
  • 3
  • 12
  • 28