Pergunta

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?

Foi útil?

Solução

Use coredata:

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

Outras dicas

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

as.numeric(Reg.curve)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top