[R] Change intervals in apply.weekly
Giuseppe Vittucci
ignatiusreilly75 at yahoo.it
Mon Dec 6 15:42:36 CET 2010
I am using the function apply.weekly() from the xts package and I
realized that for the program the week starts Tuesday.
So for instance, with a series like this:
Close
2006-07-03 36666.00
2006-07-04 36738.00
2006-07-05 36207.00
2006-07-06 36534.00
2006-07-07 36434.00
2006-07-10 36588.00
2006-07-11 36210.00
2006-07-12 36298.00
2006-07-13 35774.00
2006-07-14 35445.00
2006-07-17 35286.00
2006-07-18 35183.00
...
Where 2006-07-03 was Monday.
With this command:
p <- apply.weekly(Close,first)
Here is the series computed:
[,1]
2006-07-03 36666.00
2006-07-10 36738.00
2006-07-17 36210.00
...
p <- apply.weekly(Close,mean)
[,1]
2006-07-03 36666.00
2006-07-10 36500.20
2006-07-17 35802.60
...
Is there any command to set the week starting from Monday?
Thanks
Giuseppe
More information about the R-help
mailing list