问题描述
我正在使用data.table J在5列上做 th1
的子集: split1,market,dept_size,bool_3,cust_poor_rich
。
I am using data.table J to do subsets of th1
on 5 columns: split1, market, dept_size, bool_3, cust_poor_rich
.
我知道我应该使用 unique(column_name)
来指定应包含任何值
I understand I should use unique(column_name)
to specify that any value should be included for that column.
尽管我使用此命令遇到以下警告:
Though I am running into the following warning with this command:
setkey(th1, split1, market, dept_size, bool_3, cust_poor_rich)
subs = th1[J(0, unique(market), unique(dept_size), 1, factor(1)), nomatch=0]
Warning message:
In as.data.table.list(i) :
Item 3 is of size 5 but maximum size is 34 (recycled leaving a remainder of 4 items)
我尝试用一个小例子重现该错误,但无法重现。
I tried to reproduce the error with a small example, but cannot reproduce.
我想项目3
是指J()中的第三个输入,我可以看到 length(unique(th1 $ dept_size))
是5。
I suppose Item 3
refers to the third input in J(), and I can see that length(unique(th1$dept_size))
is 5.
但是 34 $ c在哪里$ c>来自何方?
以及为什么要剩余4个项目?
But where does the 34
comes from ? and why leaving a remainder of 4 items?
推荐答案
您可以使用 CJ
获取所有唯一组合而不是所有唯一值。
You could use CJ
to get all unique combinations instead of all unique values.
th1[CJ(0, unique(market), unique(dept_size), 1, factor(1)), nomatch=0]
这篇关于data.table警告-项目大小,但最大大小(回收后剩余项目剩余)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!