在日期范围内每天添加参考
**** 更新,因为我错过了一些有价值的信息,即日期记录在数据集中不是唯一的。****
我确信这很简单,但如果不手动查找,我无法弄清楚如何做到这一点各个日期和参考文献的表。
我有一个日期表(年/月/日)和几个日期范围。
我的日期如下所示:
日期 |
---|
2022/4/11 |
2022/4/12 |
2022/4/13 |
2022/4/13 |
2022/4/13 |
2022/4/13 |
2022/4/13 |
2022/4/14 |
2022/4 /14 |
2022/4/14 |
2022/4/15 |
2022/4/16 |
2022/4/16 |
2022/4/16 |
我的日期范围如下所示:
Start.date | Completed.date |
---|---|
2022/4/13 | 2022/4/16 |
如何添加列来显示日期系列?我的输出应如下所示:
Date | Date.number |
---|---|
2022/4/11 | |
2022/4/12 | |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/14 | 2 |
2022/4/14 | 2 |
2022/4/14 | 2 |
2022/4/15 | 3 |
2022/4/16 | 4 |
2022/4/16 | 4 |
2022/4/16 | 4 |
2022/4/17 | |
2022/4/17 | |
2022/4/18 |
提前感谢您的帮助。
表的代码:
Date.range <- structure(list(Start.date = "2022/4/13", Completed.date = "2022/4/16"), class = "data.frame", row.names = c(NA,-1L))
Date <- structure(list(Date = c("2022/4/11", "2022/4/12", "2022/4/13",
"2022/4/14", "2022/4/14","2022/4/14","2022/4/15", "2022/4/16","2022/4/16","2022/4/16",
"2022/4/17","2022/4/17","2022/4/18")), class = "data.frame", row.names = c(NA,-6L))
**** updated as I missed a valuable bit of information that the date records are not unique in the dataset.****
I'm sure this is straightforward but I can't figure out how to do this without a manual lookup table of individual dates and references.
I have a table of dates (y/m/d) and several date ranges.
My dates look like this:
Date |
---|
2022/4/11 |
2022/4/12 |
2022/4/13 |
2022/4/13 |
2022/4/13 |
2022/4/13 |
2022/4/13 |
2022/4/14 |
2022/4/14 |
2022/4/14 |
2022/4/15 |
2022/4/16 |
2022/4/16 |
2022/4/16 |
My date range looks like this:
Start.date | Completed.date |
---|---|
2022/4/13 | 2022/4/16 |
How do I add a column to show the date series? My output should look like:
Date | Date.number |
---|---|
2022/4/11 | |
2022/4/12 | |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/13 | 1 |
2022/4/14 | 2 |
2022/4/14 | 2 |
2022/4/14 | 2 |
2022/4/15 | 3 |
2022/4/16 | 4 |
2022/4/16 | 4 |
2022/4/16 | 4 |
2022/4/17 | |
2022/4/17 | |
2022/4/18 |
Advanced thanks for any help.
Code for tables:
Date.range <- structure(list(Start.date = "2022/4/13", Completed.date = "2022/4/16"), class = "data.frame", row.names = c(NA,-1L))
Date <- structure(list(Date = c("2022/4/11", "2022/4/12", "2022/4/13",
"2022/4/14", "2022/4/14","2022/4/14","2022/4/15", "2022/4/16","2022/4/16","2022/4/16",
"2022/4/17","2022/4/17","2022/4/18")), class = "data.frame", row.names = c(NA,-6L))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

一个可能的解决方案:
A possible solution: