2011-09-10 85 views
3

我正在嘗試使用quantmod website for a 3d graph上的代碼。我按照指示進入了2010年的年份(自2008年以來沒有找到鏈接)。然而,當我於R提示符下輸入以下命令:quantmod 3d圖形

chartSeries3d0(TR) 

我得到以下錯誤:

Error in if (on == "years") { : missing value where TRUE/FALSE needed 

我是比較新的R,所以任何人都可以幫我解決這個問題。

回答

3

財政部自該示例創建後重新設計了網站,因此代碼不會下載任何數據(無論您輸入什麼年份)。而不是使用getUSTreasuries函數,您可以從FRED中提取數據。

library(quantmod) 
source("http://www.quantmod.com/examples/chartSeries3d/chartSeries3d.alpha.R") 

getSymbols("DGS1MO;DGS3MO;DGS6MO;DGS1;DGS2;DGS3;DGS5;DGS7;DGS10;DGS20;DGS30", 
    src="FRED") 
TR <- merge(DGS1MO,DGS3MO,DGS6MO,DGS1,DGS2,DGS3,DGS5, 
    DGS7,DGS10,DGS20,DGS30, all=FALSE) 
colnames(TR) <- c("1mo","3mo","6mo","1yr","2yr","3yr","5yr", 
    "7yr","10yr","20yr","30yr") 
TR <- na.locf(TR) 

chartSeries3d0(TR["2011"]) 
+0

明白了......它的工作,謝謝約書亞 – itcplpl