quantmod :: chartSeries不绘制所有组件

Bea*_*min 2 r quantmod

我已经阅读了很多R文档,但我找不到任何我认可的答案.我的额头因敲打桌子而感到酸痛.;)

这是具体的library(quantmod),因为这是我想要学习的东西,但我想这也是一个普遍的问题.

R 2.12.2 GUI 1.36 Leopard构建64位(5691)Mac OS X 10.6.6

我试图quantmodhttp://www.quantmod.com/examples/intro/上复制一个例子的行为

从GUI,一切都很好 - 下面生成一个这样的图表http://www.quantmod.com/examples/intro/AAPL-full.png:

> require(TTR)
> getSymbols("AAPL")
[1] "AAPL"
> chartSeries(AAPL)
> addMACD()
> addBBands()
Run Code Online (Sandbox Code Playgroud)

但是当我source()从GUI获得一个.R文件时,我只得到了图表

> chartSeries(AAPL)
Run Code Online (Sandbox Code Playgroud)

也就是说,只有价格图表和它下面的交易量表.此外,如果我从命令行尝试以下操作,它可以按预期工作.

$ R --no-save `<`quantmod.R
Run Code Online (Sandbox Code Playgroud)

Rplots.pdf生成一个名为的文件,其中包含三个页面.第三页包含价格+成交量+ MACD +布林带.

如何quantmod让生活变得如此困难?或者我不明白这是多么明显,让生活变得如此困难?

我需要做些什么才能使源脚本能够使用图表中的函数addMACD()addBBands()函数?

作为一个附带问题,数据生成addMACD()addBBands()存储在哪里?

Jos*_*ich 6

在阅读了quantmod文档之后,在敲打桌面之前,尝试搜索R-SIG-Finance邮件列表档案(一种方式是通过rseek.org上的"支持列表"选项卡).这个问题在名单上出现了好几次.

要回答您的主要问题,请参阅以下"注意"部分?TA:

 Calling any of the above methods from within a function or script
 will generally require them to be wrapped in a ‘plot’ call as they
 rely on the context of the call to initiate the actual charting
 addition.
Run Code Online (Sandbox Code Playgroud)

所以你应该将示例更改为:

> require(TTR)
> getSymbols("AAPL")
[1] "AAPL"
> chartSeries(AAPL)
> plot(addMACD())
> plot(addBBands())
Run Code Online (Sandbox Code Playgroud)

要回答您的问题,请参阅"和"部分?chartSeries,以及help("chob-class")help("chobTA-class").