I want to extract the numerical values of a xts object. Let's look at an example
data <- new.env()
starting.date <- as.Date("2006-01-01")
nlookback <- 20
getSymbols("UBS", env = data, src = "yahoo", from = starting.date)
Reg.curve <- rollapply(Cl(data$UBS), nlookback, mean, align="right")
The Reg.cuve
is still a xts object but actually I'm just interested in the running means. How can I modify Reg.curve
to get a numerical vector?
Use coredata
:
reg.curve.num <- coredata(Reg.curve)
# or, if you want a vector:
reg.curve.num <- drop(coredata(Reg.curve))