Pergunta

Can I use barplot to plot xts objects? Or is there any similar function that I can use? quantmod is not what I'm talking about since it's not flexible enough and not compatible with other R graphics.

Foi útil?

Solução

You can extract the indices and the values of an xts or zoo object with index and coredata: this should suffice to plot it the way you want.

# Sample data
library(quantmod)
getSymbols("^GSPC")
x <- Vo( GSPC )

# Base graphics
plot( index(x), coredata(x), type="h" )

# ggplot2
d <- data.frame( time=index(x), volume=drop(coredata(x)) )
library(ggplot2)
ggplot(d, aes(time, volume)) + geom_bar(stat="identity")
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top