1
由於與par(mfrow)函數的兼容性問題繪製多個圖表,我正在使用chart_Series函數來代替chartSereis。 當我使用chart_Series函數時,我遇到了錯誤,如下所示。它必須源自char_Serires。因爲我一行一行地運行代碼。使用chart_Series quantmod包得到多個圖表
Error in plot.window(c(1, 0), c(NaN, NaN))
整個代碼如下
library(Rbbg)
library(quantmod)
conn<-blpConnect()
currency <- c("NZD Curncy", "AUD Curncy")
fld <- c("PX_OPEN", "PX_HIGH", "PX_LOW","PX_LAST")
par(mfrow=c(2,1))
par(mar = c(3, 3, 1, 0), oma = c(1, 1, 1, 1))
for (i in 1:2){
crcy<-bdh(conn,currency[i],fld,Sys.Date()-365)
Name<-as.character(bdp(conn,currency[i],"NAME"))
crcy_xts <- as.xts(crcy[,-1])
crcy.ohcl<-as.quantmod.OHLC(crcy_xts,col.names = c("Open", "High","Low", "Close"))
chart_Series(crcy.ohcl,name=Name,theme=chartTheme("white"),type='candles',TA=NULL,subset='last 6 months')
請幫助我。
這裏是再現
> head(crcy.ohcl)
crcy_xts.Open crcy_xts.High crcy_xts.Low crcy_xts.Close
2014-10-27 0.7853 0.7903 0.7846 0.7894
2014-10-28 0.7894 0.7959 0.7884 0.7919
2014-10-29 0.7919 0.7978 0.7770 0.7802
2014-10-30 0.7802 0.7827 0.7774 0.7798
最小數據。
crcy
row.names date PX_OPEN PX_HIGH PX_LOW PX_LAST
1 2014-10-29 2014-10-29 0.7919 0.7978 0.7770 0.7802
2 2014-10-30 2014-10-30 0.7802 0.7827 0.7774 0.7803
crcy_xts
row.names PX_OPEN PX_HIGH PX_LOW PX_LAST
1 2014-10-29 0.7919 0.7978 0.7770 0.7802
2 2014-10-30 0.7802 0.7827 0.7774 0.7803
感謝Jochua。我已經嘗試過,如下所示。它看起來不缺少價值。 >範圍(crcy.ohcl) [1] 0.7709 0.8836 – 2014-10-30 07:39:20
@JaeHoon:如果我不能重現錯誤,我無法幫到你。請提供創建[可重現示例]所需的最小數據量(http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)。 – 2014-10-30 16:06:48
我剛剛更新了我的問題以顯示最小數據,以便您可以重現。我希望這對你有好處。感謝Joshua。 – 2014-10-30 23:35:49