Displaying 1 result from an estimated 1 matches for "sp500wd".
Did you mean:
sp500
2012 Aug 05
1
R: Help xts object Subset Date by Day of the Week
...ly closing prices I have acquired using
quantmod.
Here is my code:
library(xts)
library(quantmod)
library(lubridate)
# Gets SPY data
getSymbols("SPY")
# Subset Prices to just closing price
SP500 <- Cl(SPY)
# Show day of the week for each date using 2-6 for monday-friday
SP500wd <- wday(SP500)
# Add Price and days of week together
SP500wd <- cbind(SP500, SP500wd)
# subset Monday into one xts object
SPmon <- subset(SP500wd, SP500wd$..2=="2")
I then used the package lubridate to show the days of the week. Due to the
requirement of an xts objec...