Pull nth Day of Month in XTS in R
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: library(xts) data(sample_matrix) x <- as.xts(sample_matrix) Here's the subsetting: x[format(index(x), "%d") == "10"] # Open High Low Close # 2007-01-10 49.91228 50.13053 49.91228 49.97246 # 2007-02-10 50.68923 50.72696