My questions is closely related to the one asked here: Pull Return from first business day of the month from XTS object using R.
Instead of extracting the first day of each month, I want to extract, say the 10th data point of each month. How can I do this?
Using the same example data from the question you’ve linked to, you can do some basic subsetting.
Here’s the sample data:
Here’s the subsetting:
Is this what you were looking for?
Using
%in%would give you some more flexibility. For instance, if you wanted the tenth, eleventh, and twelfth days of each month, you could usex[format(index(x), "%d") %in% c("10", "11", "12")]instead.Update
If, as you have in your update, you want to extract the tenth data point, just use an anonymous function as follows:
Note that the first row is the eleventh day of the month, because the data actually starts on January 2, 2007.