- 已编辑
如果我没理解错的话,这不就是个 seq
+ mapply
+ table
的问题嘛……
# 构建数据:
date_df <- data.frame(start = c("06-01","06-02","06-03","06-04","06-04"),
duration = c(4,3,1,1,0))
# 识别日期:
date_df$ystart <- as.Date(paste0('2019-', date_df$start))
# 生成所有日期:
date_ls <- mapply(function(x1, x2) format(seq(from = x1, length.out = x2, by = 1), '%m-%d'),
date_df$ystart, date_df$duration)
# 统计频次:
table(unlist(date_ls))