我为400.000 ID发了一系列回归。我有以下长数据集(1个ID的例子)
ID variable measure value
7.301004e+18 (Intercept) Estimate 1.225463e+02
7.301004e+18 price Estimate -1.055974e+02
7.301004e+18 pricepromo Estimate 3.085680e-01
7.301004e+18 feature Estimate 1.629105e+00
7.301004e+18 display Estimate 2.171643e+01
7.301004e+18 trend Estimate -1.148725e-02
7.301004e+18 addition_step Estimate -4.813033e-01
7.301004e+18 (Intercept) Std. Error 1.674007e+01
7.301004e+18 price Std. Error 1.724551e+01
7.301004e+18 pricepromo Std. Error 2.051796e-01
7.301004e+18 feature Std. Error 3.010596e+00
7.301004e+18 display Std. Error 3.580683e+00
7.301004e+18 trend Std. Error 1.297774e-02
7.301004e+18 addition_step Std. Error 2.400008e+00
7.301004e+18 (Intercept) Pr(>|t|) 1.022462e-12
7.301004e+18 price Pr(>|t|) 1.885259e-09
7.301004e+18 pricepromo Pr(>|t|) 1.332546e-01
7.301004e+18 feature Pr(>|t|) 5.886688e-01
7.301004e+18 display Pr(>|t|) 2.645076e-09
7.301004e+18 trend Pr(>|t|) 3.765107e-01
7.301004e+18 addition_step Pr(>|t|) 8.411398e-01
我需要重新整形,以便每个变量*度量组合都有1列。变量有8个级别,度量有3个级别,所以我创建了21个列。
我使用以下代码(基于reshape2
)来执行此操作:
reshaped <- dcast(mydata, ID ~ measure + variable, value.var = "value")
问题是在我的输出中我只剩下3.229个观测值(尽管我在长数据集中有2885342个观测值)。
另外,我收到以下错误:
&#34;缺少聚合函数:默认为长度&#34;。
我不明白我为什么要聚合。我希望每个唯一ID有一个观察结果。