2014-02-11 34 views
0

我想對我的數據使用R性能分析。我從數據庫中獲取數據,它看起來像這樣:R性能分析不起作用

PnL<-GetDRWPnLByDesk("Entity A") # this gets the data from the database 
head(PnL) 

這裏的數據是什麼樣子:

businessdate  PnL 
1 2014-01-01  40.39 
2 2014-01-02 48.42 
3 2014-01-03 17.00 
4 2014-01-06 -925.71 
5 2014-01-07 -1020.52 

這裏是我的2列類

class(PnL$businessdate) [1] "POSIXct" "POSIXt"

> class(PnL$PnL) [1] "numeric" 

現在我想使用charts.PerformanceSummary()函數,所以我創建了一個時間序列對象並嘗試使用它:

PnL_TS <- xts(PnL$PnL, order.by=as.Date(PnL$businessdate, format="%Y%m%d")) 
charts.PerformanceSummary(PnL_TS) 

但我得到一個錯誤: 錯誤TS(損益$損益,開始=分鐘(損益$ businessdate),結束= MAX(損益$ businessdate)): 無效的時序參數所指定

任何想法如何解決它?

謝謝。

+0

這是爲什麼標籤SAS? – scott

+0

這是一個錯誤,我刪除了SAS標籤。 – user3022875

回答

0

這可能是因爲您的載體PnL_TS的.... charts.PerformanceSummary(x) x : an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns

PnL_TS <- ROC(PnL_TS) # convert to log returns 
charts.PerformanceSummary(PnL_TS) # plot