I have a time Series DataFrame:
[https://www.dropbox.com/s/elaxfuvqyip1eq8/SampleDF.csv?dl=0][1]
My intention is to divide this DataFrame into different seasons according to:
- winter: Dec Jan Feb
- Pre-monsoon: Mar Apr May Jun15 (i.e. till 15th of June)
- Monsoon: 15Jun Jul Aug Sep (i.e. from 15th of June)
- Post-monsoon: Oct Nov.
I tried using openair package function
selectByDate()
But no luck yet. Being novice in R. Any help would be highly appreciated.
Thanks!
Please see the
lubridatepackage which makes working with date/time a bit easier.For your problem, I guess you can use
sapply:where,
assign_season:once you have seasons, then you can divide the dataframe easily:
Sorry, I have to rush now, but can come back and finish this, if someone else hasn't answered already.
EDIT:
So, R does have a built in function
cut, that can work on dates and split a vector based on date ranges.For your data, I did this like so:
Now, the splits list should have all the data you need