【发布时间】:2014-05-28 15:00:44
【问题描述】:
我有 2 个数据表:
- train.o 有 160057 行,列 id 是唯一的
- train.t有187105085行,列id不唯一,有160057个唯一id,都在train.o
我想合并它,得到一个包含 187105085 行的单个 data.table。
当我输入时
> setkey(train.o,id)
> setkey(train.t,id)
> trainbig=merge(train.t,train.o)
我明白了
vecseq(f__, len__, if (allow.cartesian) NULL else as.integer(max(nrow(x), : 连接结果超过 2^31 行 (内部 vecseq 达到物理极限)。很可能指定错误 加入。检查 i 中的重复键值,每个键值都连接到 x 中的同一组一遍又一遍。如果没问题,请尝试包含
j并删除by(by-without-by) 以便 j 为每个组运行 避免大分配。否则请搜索此错误 FAQ、Wiki、Stack Overflow 和 datatable-help 中的消息 建议。
我做错了什么?
编辑:
> head(train.o)
offer id chain market repeattrips repeater offerdate category quantity company
1: 1197502 86252 205 34 16 t 2013-03-27 3203 1 106414464
2: 1208251 86246 205 34 5 t 2013-04-24 2202 1 104460040
3: 1197502 12682470 18 11 0 f 2013-03-28 3203 1 106414464
4: 1197502 12996040 15 9 0 f 2013-03-25 3203 1 106414464
5: 1204821 13089312 15 9 0 f 2013-04-01 5619 1 107717272
6: 1197502 13179265 14 8 0 f 2013-03-29 3203 1 106414464
offervalue brand
1: 0.75 13474
2: 2.00 3718
3: 0.75 13474
4: 0.75 13474
5: 1.50 102504
6: 0.75 13474
> head(train.t)
id chain dept category company brand date productsize productmeasure
1 86246 205 7 707 1078778070 12564 2012-03-02 12 OZ
2 86246 205 63 6319 107654575 17876 2012-03-02 64 OZ
3 86246 205 97 9753 1022027929 0 2012-03-02 1 CT
4 86246 205 25 2509 107996777 31373 2012-03-02 16 OZ
5 86246 205 55 5555 107684070 32094 2012-03-02 16 OZ
6 86246 205 97 9753 1021015020 0 2012-03-02 1 CT
purchasequantity purchaseamount
1 1 7.59
2 1 1.59
3 1 5.99
4 1 1.99
5 2 10.38
6 1 7.80
【问题讨论】:
-
至少向我们展示您的数据集的结构、列名,并告诉我们您要加入的列上没有重复的元素。
-
数据来自 [link]kaggle.com/c/acquire-valued-shoppers-challenge/data -train.o is merge(trainHistory,offers,by="offer") -train.t is subset(transactions,id %in% trainHistory$ id) 交易文件可以通过 (id,chain) 加入到历史文件中。但是 id 和 chain 的 setkey 都没有帮助。
-
我还编辑了帖子以包含两个 data.tables 的负责人
-
sum(!duplicated(train.o$id))和sum(!duplicated(train.t$id))提供了什么? -
都是160057,我一开始就写好了。
标签: r merge data.table