对日期使用 R cut 函数
我有一个数据框,提供体育赛事的出席情况
Crowd matchDate
2345 1993-01-26
4567 1993-08-01
8888 1994-03-02
1298 1994-11-07
9876 1995-09-01 etc
1237 2011-09-09
matchdate 是一个 POSIXct 类
我希望能够根据日期创建一个季节因素,例如每个季节从 8 月 1 日到 7 月 31 日,例如因素 1992/3 将包括日期 1992-08-01 到 1993-07-31
理想情况下,这将是我可以应用于多项分析的函数,不一定具有相同的开始和结束日期
I have a dataframe giving attendances at sports events
Crowd matchDate
2345 1993-01-26
4567 1993-08-01
8888 1994-03-02
1298 1994-11-07
9876 1995-09-01 etc
1237 2011-09-09
The matchdate is a POSIXct class
I want to be able to create a season factor based on the date such that each season runs from, say, 1st August to 31 July e.g factor 1992/3 would include dates 1992-08-01 to 1993-07-31
ideally it would be a function that I could apply for several analyses, not necessarily with same start and end dates in the year
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的评论的一个例子。
然后根据需要重新标记。
An example of my comment.
And then relabel as you please, if necessary.
如果您的问题与如何自动生成中断和标签更相关,也许这会有所帮助
If your question is more related to how you automatically generate the breaks and labels, maybe this will help