如何使用多个键来选择某些行

时间:2018-05-22 02:30:36

标签: r data.table

例如,我有这样的data.table

library(data.table)

test <- data.table(x=c(rep(c(1:3),3)),y=c("A","B","A","C","C","B","B","B","A"))

enter image description here

我设置了两个键,x和y setkey(test,x,y);

然后我想选择&#34; x&#34; == 1或2和&#34; y&#34; ==&#34; A&#34;或&#34; B&#34;;

但如果我输入test[list(c(1,2),c("A","B"))] 我错了enter image description here

我怎样才能得到我想要的东西,谢谢!!!

0 个答案:

没有答案