[R-SIG-Finance] Closest weekly endpoint to the fifteenth of the month

Ilya Kipnis ilya.kipnis at gmail.com
Thu Oct 20 17:54:17 CEST 2016


Hi there. I have a question about custom endpoints. Currently, in R, you
can set endpoints to weekly, monthly, quarterly, etc...

However, I was wondering if there was a way to do this:

Assuming you have weekly endpoints, is there a way to select, in each
month, the day closest to the fifteenth--AKA middle of the month?

Right now, my idea is to loop through each individual month, subtract 15
from each date, end pick the one closest to zero, and index it. I was
wondering if there's a more elegant method of doing this.

Thanks.

-Ilya

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list