如何在几个月内分发价值? #r
当前,我的数据有一个用于start_date的columne,并且列为end_date。
对于每个时间段(起始末端),侧面A和侧面b的死亡人数众多。我想在几个月中分配这些值。
有时,它在同一个月和年份开始并结束(假设2020年3月),如果Deyts_a为10,那么我想在2020年3月有10个
。有时,它开始在三月开始,并于4月结束。如果Deaths_a是10岁,那么我想在3月有5个,四月的5个。
我应该如何处理?
谢谢你!
Currently, my data has a columne for start_date and a column for end_date.
For each time period (start-end), there are values like number of deaths of side a and side b. I want to divide the values across months.
Sometimes, it started and ended in the same month and year (let's say March 2020), and if deaths_a is 10, then I want to have 10 for March 2020.
Sometimes, it started in let's say March and ended in April. If deaths_a is 10, then I want to have 5 for March and 5 for April.
How should I approach this?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用橄榄酸软件包将解决。假设您总是有时间的时间顺序。
由于我们假设时间序列增加,因此也适用于负面的“月_diff”。
Using Lubridate package will solve. Assume you always have increasing order of time.
Also works for negative "month_diff" since we assume an increasing sequence of time.