Winsor返回函数

时间:2016-03-17 12:53:42

标签: r psych

下面是一个动物园对象的摘录,我试图使用winsor包中的psych来赢取这个对象:

x <- structure(c(0.0400337546529555, -0.0320371743076633, 0.0106006766976862, 
-0.011406282992093, -0.018676165248018, 0.0275956214868875, 0.00473575019758404, 
0.0986083620222542, 0.00615420656427005, 0.00709069372334476), .Names = c("1984-01", 
"1984-02", "1984-03", "1984-04", "1984-05", "1984-06", "1984-07", 
"1984-08", "1984-09", "1984-10"), index = structure(c(5113, 5144, 
5173, 5204, 5234, 5265, 5295, 5326, 5357, 5387), class = "Date"), class = c("zooreg", 
"zoo"), frequency = 1)

我用:

winsor(x, trim=0.1)

我得到以下内容:

function () 
.Last.value
<environment: namespace:gdata>

我尝试使用具有相同类别(即zoozooreg)的以下数据的函数:

a <- structure(c(1, 2, 3), .Dim = c(3L, 1L), .Dimnames = list(NULL, 
        "a"), index = structure(c(5113, 5144, 5173), class = "Date"), frequency = 1, class = c("zooreg", 
    "zoo"))

它与a一起工作正常,但不确定为什么它会针对特定类型的数据x返回上述内容。

1 个答案:

答案 0 :(得分:0)

self.transport.joinGroup('ff02:0000:0000:0000:0000:0000:0000:0001') 中的

x必须是vector,matrix或data.frame。不支持winsor个对象。首先转换/提取数据,例如:

zoo

给出

winsor(coredata(x), trim=0.1)

更新

OP问题中的> winsor(coredata(x), trim=0.1) 1984-01 1984-02 1984-03 1984-04 1984-05 1984-06 0.040033755 -0.020012266 0.010600677 -0.011406283 -0.018676165 0.027595621 1984-07 1984-08 1984-09 1984-10 0.004735750 0.045891215 0.006154207 0.007090694 缺少尺寸,添加     变暗(X)= C(10,1) 使它工作:

x