xts 对象的条形图 [英] barplot for xts objects

查看:28
本文介绍了xts 对象的条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 barplot 来绘制 xts 对象吗?或者我可以使用任何类似的功能吗?quantmod 不是我要说的,因为它不够灵活并且与其他 R 图形不兼容.

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.

推荐答案

您可以提取索引和值带有 index 的 xts 或 zoo 对象和 coredata:这应该足够了以您想要的方式绘制它.

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")

这篇关于xts 对象的条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆