2014-03-27 26 views
5

我有一個看起來像這樣的數據框「測試」。沒有N/A或inf。所有的日子都充滿了數據。性能分析錯誤na.omit.xts(x)中的錯誤:不支持的類型

head(test) 

    businessdate strategy 1   Strategy 2 
1 2014-01-01 0.000000000   0.0000000 
2 2014-01-02 0.010058520   -0.3565398 
3 2014-01-03 0.000707818   0.2622737 
4 2014-01-06 -0.019879142   -0.2891257 
5 2014-01-07 -0.019929352   -0.2271491 
6 2014-01-08 0.027108810   -0.7827856 

當我看I類看到這些列:

> class(test[,1]) 
[1] "POSIXct" "POSIXt" 
> class(test[,2]) 
[1] "numeric" 
> class(test[,3]) 
[1] "numeric" 

所以我想我可以把它變成一個XTS對象和使用性能分析。在這裏,我把它變成一個XTS:

test_xts<- xts(test, order.by= test[,1]) 

現在我嘗試使用性能分析軟件包,並得到一個錯誤:

charts.PerformanceSummary(test_xts,geometric= TRUE,cex.axis=1.5) 

我得到的錯誤是:

Error in na.omit.xts(x) : unsupported type 

任何想法發生了什麼以及如何解決它?

回答

5

xts/zoo對象是一個帶有索引屬性的矩陣。你不能在矩陣中混合類型。沒有必要在coredata中指定businessdate作爲索引,所以不要將其包含在coredata中。

test_xts <- xts(test[,-1], order.by= test[,1]) 
相關問題