从控制台执行与从 TextMate 执行时,R quantmod 包的行为不同
代码如下:
require("quantmod")
getSymbols("GLD")
getSymbols("SLV")
getSymbols("TLT")
GSR = GLD/SLV
par(mfrow=c(2,2))
chartSeries (GLD, subset="2010", TA = NULL)
chartSeries (SLV, subset="2010", TA = NULL)
chartSeries (TLT, subset="2010", TA = NULL)
chartSeries (GSR, subset="2010", TA = NULL)
当我使用 Command R 按键从 TextMate 运行此文件时,我得到了四个排列在 2 x 2 网格中的图表,正如您对 par() 函数所期望的那样。当我从 R 控制台获取此数据时,
> source("~/myChartSeries.r")
我会看到每个图表的闪现,其中最后一个图表被单独描绘。我最后一次听到的说法是,chartSeries() 与 par() 函数不兼容,但 Chart_Series() 是。所以控制台的行为并不奇怪。但为什么 TextMate 的执行能起作用呢? ChartSeries() 是否已与 par() 兼容并且 R 控制台执行是否存在缺陷?
Here is the code:
require("quantmod")
getSymbols("GLD")
getSymbols("SLV")
getSymbols("TLT")
GSR = GLD/SLV
par(mfrow=c(2,2))
chartSeries (GLD, subset="2010", TA = NULL)
chartSeries (SLV, subset="2010", TA = NULL)
chartSeries (TLT, subset="2010", TA = NULL)
chartSeries (GSR, subset="2010", TA = NULL)
When I run this file from TextMate with the Command R keystroke, I get four charts lined up in a 2 x 2 grid, as you'd expect from the par() function. When I source this from the R console,
> source("~/myChartSeries.r")
I get a flash of each chart with the last one depicted alone. The last I'd heard, chartSeries() was not compliant with the par() function but chart_Series() is. So the behavior of the console is not surprising. But why does execution from TextMate work? Has chartSeries() been made par() compliant and is the R console execution flawed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当代码从 TextMate 运行时,它会分别打印所有四个图表,并产生“错觉”,认为它是具有四个面板的单个图表。事实上,当我注释掉 par() 函数时,
我得到了相同的结果。所以看来 ChartSeries() 仍然不符合 par() 标准。
When the code is run from TextMate, it prints all four charts separately with the 'illusion' that it is a single chart with four panels. In fact, when I comment out the par() function,
I get the same result. So it appears that chartSeries() is still not par() compliant.
这对我来说无论在哪个位置都适用:
希望这有帮助。
this works for me from either location:
Hope this helps.