Young Cho
2007-Mar-15 04:10 UTC
[R] timeDate object - days, months manipulation & arithmetic
Hi, Thanks so much in advance for your help! I just started using 'timeDate' object to manipulate daily time series data. After reading some documents, I created an object 'bizday' to do some business-day computation. E.g. > bizday = timeSequence (from='20010101',to='20070313',by='day',FinCenter + ='America/Eastern') > bizday = bizday[ isBizday(bizday,holidays=holiday.NYSE(2001:1007)) ] Now, I can find what month ith business day is in, or add 10 business days to it: > i = 100 > bizday[100] [1] "America/Eastern" [1] [2001-05-24] > format(bizday[i],'%Y%m') [1] "200105" > format(bizday[i+10],'%Y%m') [1] "200106" But, I want to get the previous month for the ith business day. for the above example, it would be "200104". How can I do that? Are there some functions ( or even other pkg) dealing w/ these ? Or, am I doing it in a bad way and there is much simpler & clean way of doing stuff like this? Any advice will be greatly appreciated. Young.