I have an xts object called Daily_Quotes
that contains stock quotes. I'm using endpoints
to get monthly stock quotes that I retrieved using getSymbols
(from the quantmod package). I noticed that the endpoints
function creates an index of the row that contains the last trading day for the particular month and assigns it to the new object for the specified date range. Is there anyway to get first trading day of the month instead?
# My code
Monthly_Quotes <- Daily_Quotes[endpoints(Daily_Quotes,'months')]
What I tried doing was:
# This gave me the next day or 1st day of the next month
# or next row for the object.
endpoints(Daily_Quotes,'months') + 1
# So I applied this and it gave me
# Error in `[.xts`(Daily_Quotes, endpoints(Daily_Quotes, "months") + 1) :
# subscript out of bounds
Monthly_Quotes <- Daily_Quotes[endpoints(Daily_Quotes,'months') + 1]
How do I attempt to solve this ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…