Question

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?

Était-ce utile?

La solution

Use coredata:

reg.curve.num <- coredata(Reg.curve)
# or, if you want a vector:
reg.curve.num <- drop(coredata(Reg.curve))

Autres conseils

To extract the numerical values of any xts, ts, or zoo object use:

as.numeric(Reg.curve)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top