【发布时间】:2012-03-06 22:26:21
【问题描述】:
我可以使用 barplot 来绘制 xts 对象吗?或者我可以使用任何类似的功能吗? quantmod 不是我要说的,因为它不够灵活且与其他 R 图形不兼容。
【问题讨论】:
-
基本 R 图中的任何解决方案?
我可以使用 barplot 来绘制 xts 对象吗?或者我可以使用任何类似的功能吗? quantmod 不是我要说的,因为它不够灵活且与其他 R 图形不兼容。
【问题讨论】:
您可以提取索引和值
带有index 的 xts 或 zoo 对象
和coredata:这就足够了
以你想要的方式绘制它。
# 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")
【讨论】: