質問

テキストファイル内のデータの一部:

date,p
2013-11-14,0.001
2013-11-13,-0.005
2013-11-12,0.001

library(PerformanceAnalytics)
stuff<-read.csv("C:stuffexample.txt")
str(stuff)

'data.frame':   3 obs. of  2 variables:
 $ date: Factor w/ 3 levels "2013-11-12","2013-11-13",..: 3 2 1
 $ p   : num  0.001 -0.005 0.001
.

データのパフォーマンス分析を使用したい:

AverageDrawdown(stuff)

Error in checkData(R) : 
  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'. 

table.Drawdowns(box)

Error in checkData(R[, 1, drop = FALSE]) : 
  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'. 
.

エラーを修正する方法?

役に立ちましたか?

解決

エラーに記載されているアドバイスに従う必要があります。データの行名とデータのみのデータの行名が必要です.frame:

row.names(stuff) <- levels(stuff$date)[stuff$date]
stuff2 <- stuff[, 'p', drop=FALSE]

AverageDrawdown(stuff2)
.

これは再現可能な例を提供していないので、これはテストされていません...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top