'我是R新手,甚至更多的對象。我嘗試從數據框(df)的矢量上使用PerformanceAnalytics包。錯誤:order.by需要適當的基於時間的對象PerformanceAnalytics
我有以下的數據幀:
row.names Date PnL
1 22 1992-01-02 -1.751133e-02
2 23 1992-01-03 -1.586737e-02
3 24 1992-01-06 -2.898982e-02
我嘗試:
TestS=SharpeRatio.annualized(df[,"PnL"],Rf=0,scale=252)
TestS=SharpeRatio.annualized(as.ts(df[,"PnL"]),Rf=0,scale=252)
它在對象分別返回錯誤和:
Error in checkData(R, method = "xts") : The data cannot be converted into a time series. If you are trying to pass in names from a data object with one column, you should use the form 'data[rows, columns, drop = FALSE]'. Rownames should have standard date formats, such as '1985-03-15'
dput(df[,"PnL")=0.00994504296273811, 0.00156467225423175, 0.00976137048829638, etc.
dputdf[,"Date")=8036, 8037, 8040, 8041,etc.
程序包的幫助說功能有效在向量上。我沒有任何NA,因此我不明白爲什麼它不起作用。
這不是一個很好的使用'dput'。 dput的目的是以保留數據的結構和屬性等方式來共享數據,這些數據可能(在這種情況下)會影響數據的處理方式。您可以從錯誤中看到,您的對象不是函數期望的「xts」時間序列。 – A5C1D2H2I1M1N2O1R2T1 2012-07-12 10:09:43