data.table vs plyr regression output

后端 未结 1 374
感情败类
感情败类 2020-12-14 19:55

The data.table package is very helpful in terms of speed. But I am having trouble actually using the output from a linear regression. Is there an easy way to get the data.

相关标签:
1条回答
  • 2020-12-14 20:55

    Try this:

    > REG[, as.list(coef(lm(y ~ x + z))), by=ID];
            ID (Intercept)           x         z
    [1,] Frank  -0.2928611  0.07215896  1.835106
    [2,]  Tony   0.9120795 -1.11153056  2.041260
    [3,]    Ed   1.0498359  5.77131778 -1.253741
    

    I have the nagging feeling that this question was asked less than a week ago, but I don't think I arrived at this approach when I tried it and I don't remember than any answer was this compact.

    Oh, there it is .. on r-help. Matthew can comment on the rightfulness of this if he wants. I guess the message is that functions returning lists will not have dimensions dropped. The interesting thing was the using list(coef(lm(...)) did not succeed in the manner we hoped.

    0 讨论(0)
提交回复
热议问题