目前只能想到对每列分类统计一下,然后再合并数据集了
# 获取首次使用起始时间、末次使用结束时间和全天使用时间
temp_start = aggregate(x = dat[,4], by= list(dat[,1], dat[,2]), FUN = min)
temp_end = aggregate(x = dat[,5], by= list(dat[,1], dat[,2]), FUN = max)
temp_duration = aggregate(x = dat[,6], by= list(dat[,1], dat[,2]), FUN = sum)
# 整理数据
names(temp_start) = c("uid", "appid", paste("start_time", chrx, sep = ''))
names(temp_end) = c("uid", "appid", paste("end_time", chrx, sep = ''))
names(temp_duration) = c("uid", "appid", paste("duration", chrx, sep = ''))
dat = merge(temp_start, temp_end, by = c("uid", "appid"))
dat = merge(dat, temp_duration, by = c("uid", "appid"))