2015-07-12 77 views
2

我用描述的功能爲我的數據的彙總統計,但我的結果是:R中描述功能(設置精度位數)

> describe(rIND) 
      vars n mean sd median trimmed mad min max range skew 
Adj.Close 1 1987 0 0.02  0  0 0.01 -0.12 0.16 0.28 0.27 
      kurtosis se 
Adj.Close  9.69 0 

其中rIND是一個時間序列。

我嘗試使用>describe(rIND, digits = 5)或其他變更精密數字變化的函數的參數,看到的「中間」的價值觀,「中庸」等

我嘗試使用描述的其他庫,例如Hmisc和lessR和Don功能沒有工作。

我該如何改變它?

我將數據轉換爲矩陣並使用describeBy。其結果是:

> class(rIND) 
[1] "matrix" 

> head(rIND) 
     [,1] 
[1,] 0.040867936 
[2,] 0.001542679 
[3,] 0.013143060 
[4,] 0.016857574 
[5,] 0.003183194 
[6,] 0.001292192 

> describeBy(rIND,mat=TRUE,digits=3) 
Error in matrix(NaN, ncol = ncol, nrow = n.var * n.groups) : 
    value of 'nrow' not valid (very large or NA) 
Warning message: 
In describeBy(rIND, mat = TRUE, digits = 3) : 
no grouping variable requested 

回答

1

您可以使用describeBy。該命令將是describeBy(rIND,group=NULL,mat=TRUE,type=3,digits=5)。隨着被設置爲您需要的任何級別的精度。由於這隻適用於返回矩陣,所以如果您仍想要列表輸出,則必須使用convert the matrix to a list of columns

請參閱the full documentation for describe.by,如果您在查找存在數據操作的方法時遇到問題,則可能會檢出the Quick-R reference guide


:這取決於您的R版本,您可能需要使用describe.by()的命令。

+0

我嘗試使用describeBy而不工作。 我接收到的消息: '>在describeBy(rBRA,數字= 5):無分組變量requested' –

+0

不工作,再次導致'沒有分組變量requested' –

+0

@FlávioCorinthians對不起,忘記設置矩陣標誌(更改爲'mat = TRUE')。由於數字只能與矩陣一起使用。如果之後需要獲取列表,則需要將其轉換。注意:如果你想擺脫分組錯誤,你只需要設置一個 – JGreenwell

0

您可以使用as.data.frame(describe(rIND)),它將使用您的R選項中指定的digits參數,併產生與describe相同的輸出。