-1
我正在尋找一種方法將df導入dfres。按日期分組並將行摺疊爲一個列
Dfres是
obj <- date #where type == I5,
min <- min(date) #where type == I6,
max <- max(date) #where type == I6,
所有這一切都通過年度區分。
year <- c('2014','2015','2016','2017','2014','2015','2016','2017','2016','2014','2015')
type <- c('I6','I6','I6','I6','I6','I6','I6','I6','I5','I5','I5')
date <- c('2014-06-03','2015-08-01','2016-06-01','2017-05-15',
'2014-04-11','2015-03-14','2016-03-17','2017-03-08','2016-11-05',
'2014-09-04','2015-05-01')
df <- data.frame(year,type,date)
year <- c('2014','2015','2016','2017')
obj <- c('2014-09-04','2015-05-01','2016-11-05',NA)
min <- c('2014-04-11','2015-03-14','2016-03-17','2017-03-08')
max <- c('2014-06-03', '2015-08-01','2016-06-01','2017-05-15')
dfres <- data.frame(year,obj,min,max)
如果有人能幫助我,沒有準備的數據,以便圍繞解決這個問題的一種方式,但一個「容易」的方式拋出了一句,我會很優雅。