Closed HalfEatenPie closed 3 years ago
I'm closing this because it's not an issue with the package, so there's nothing for me to fix. This would also be better to ask on R-SIG-Finance or StackOverflow. That said, I will still try to help.
It's not clear to me what you're trying to do. The end points you pass to period.apply()
should be the last observation in the aggregation period. The vector should always start with 0 and end with nrow(x)
. All the other points are up to you to calculate correctly.
Also, you can use .indexyear()
, .indexyday()
, and the other .index*()
functions to make some of your calculations easlier.
Description
I have a function built up using endpoints to start
period.apply()
from a different month. The current version I'm pasting below has been working for me, but recently I've started running into issues with this (fringe cases) and I wanted to spend some time understanding this a bit further.I want a
apply.yearly()
but starting at a different month. For example, my current application requires a start from October to September, but I also recognize that my code does not work for all use cases (February being the case).Expected behavior
Function working from any month seasons (February to January, October to September, etc.).
Minimal, reproducible example
Sample Data
Am I using endpoints correctly? Am I using period.apply correctly? What's the easiest and "better" way of generating the endpoints? I'd like to understand this further. I'd also like to make this in-line with how the other apply.monthly() functions operate. Can I get some guidance please?
Session Info