当条件完全满足时,子集data.table

时间:2015-09-08 20:50:05

标签: r data.table

我有一个data.table,

str(zipShp2_dt)
Classes ‘data.table’ and 'data.frame':  5567625 obs. of  7 variables:
$ lat  : num  -14.4 -14.4 -14.4 -14.4 -14.4 ...
$ long : num  -171 -171 -171 -171 -171 ...
$ order: int  5145201 5145204 5145203 5145202 5145200 5145199 5145205   5145206 5145198 5145207 ...
$ hole : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
$ piece: Factor w/ 32 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
$ group: Factor w/ 42703 levels "00601.1","00602.1",..: 40916 40916 40916    40916 40916 40916 40916 40916 40916 40916 ...
$ id   : chr  "96799" "96799" "96799" "96799" ...
- attr(*, ".internal.selfref")=<externalptr> 
- attr(*, "sorted")= chr  "lat" "long"
- attr(*, "index")= atomic  
..- attr(*, "long")= int  5392777 5392778 5392779 5392780 5392781 5392782   5392790 5392808 5392802 5392813 ...`

我想检索id值,例如:

tail(zipShp2_dt)
     lat   long   order  hole piece   group    id
1: 71.34 -156.6 5478987 FALSE     1 99723.1 99723
2: 71.34 -156.6 5478989 FALSE     1 99723.1 99723
3: 71.34 -156.6 5478986 FALSE     1 99723.1 99723
4: 71.34 -156.6 5478981 FALSE     1 99723.1 99723
5: 71.34 -156.6 5478984 FALSE     1 99723.1 99723
6: 71.34 -156.6 5478985 FALSE     1 99723.1 99723`

所以我试过

zipShp2_dt[long==-156.6]
Empty data.table (0 rows) of 7 cols: lat,long,order,hole,piece,group...

但是,我可以找到,例如

zipShp2_dt[long<-156]
lat   long   order  hole piece   group    id
1: -14.32 -170.7 5145114 FALSE     1 96799.1 96799`

除了完全符合之外,所有其他操作都是吸吮的。

data.table太大了,所以我创建了一个dput(head(zipShp2_dt)),可以在https://drive.google.com/file/d/0B31RjzxWt16hY09oM0ppU21PR2M/view?usp=sharing

找到

有什么建议吗?

0 个答案:

没有答案