我想按日期范围组织数据框。R按日期范围对数据帧进行子集
我们今天考虑的是2017年1月1日和下面的表显示:
三种类型的产品(苹果,香蕉和啤酒)
五到期日期(1/15/2017年,2017年2月27日,2017年3月15日,2017年9月1日和2018年1月10日)
Product Type 1/15/2017 2/27/2017 3/15/2017 9/1/2017 12/20/2017 1/10/2018 Apple 3 10 - 2 8 - Banana 5 50 100 10 10 2 Beer 1 1 1 1 1 1
你可以阅读上表为“店经理有3个苹果,有效日期为2017年1月15日,其他10个苹果可以持续更长时间,有效期限为2017年2月27日等。“
店长有兴趣知道有多少苹果会在不到1个月,1至3个月,3至12个月和超过12个月内到期。
如何在R中对此进行编码? 结果表是这样的:
Product Type Less than 1mth 1-3mths 3-12 mths More than 12mths Apple 3 10 10 - Banana 5 150 20 2 Beer 1 2 2 1
非常感谢你的帮助!
你有没有试图编码它?你有什么想法? –