在以下数据框中
id<-c(1,1,1,1,1,3,3,3,3)
date<-c(NA,NA,"22-11-07",NA,NA,NA,NA,"23-11-07",NA)
df<-data.frame(id,date)
df$date2<-as.Date(as.character(df$date), format = "%d-%m-%y")
id date date2
1 <NA> <NA>
1 <NA> <NA>
1 23-11-07 2007-11-22
1 <NA> <NA>
1 <NA> <NA>
3 <NA> <NA>
3 <NA> <NA>
3 23-11-07 2007-11-23
3 <NA> <NA>
有什么方法可以基于date
and进行聚合id
并获取以下数据框?
id date2
1 2007-11-22
3 2007-11-23