[R-sig-Geo] How to negate %in%

Dan Putler dan.putler at sauder.ubc.ca
Mon May 25 21:11:32 CEST 2009


Sorry, I sent my initial reply only to Jim, not the list.

Dan

-------- Forwarded Message --------
From: Jim Burke <j.burke at earthlink.net>
To: Dan Putler <dan.putler at sauder.ubc.ca>
Subject: Re: [R-sig-Geo] How to negate %in%
Date: Mon, 25 May 2009 14:01:26 -0500

Thanks Dan,

Both yours and Torleif's suggestions work with a
SpatialPolygonsDataFrame.   

It feels like Dan's suggestion works faster for
my 1,897 polygons.

Thanks again,
Jim Burke

Dan Putler wrote:
> Jim,
>
> A quick answer below.
>
> Dan
>
> On Mon, 2009-05-25 at 13:13 -0500, Jim Burke wrote:
>   
>> I can subset a "SpatialPolygonsDataFrame" from a
>> data frame containing a smaller subset of IDs. For
>> example below.
>>
>> smaller_sp <- large_sp [large_sp$ID %in% smaller_df$ID,]
>>     
>
> smaller_sp <- large_sp [!(large_sp$ID %in% smaller_df$ID),]
>   
>> Given the above how can I do the logically opposite from
>> the %in% operation and get all those IDs not %in%?
>>
>> I am processing two different sets of polygons (A,B) in
>> a loop. Operation is seeing in center points in polys B
>> fall in A. I would like to remove the spatial polygons
>> that I found (B) as I traverse the geographical area.
>>
>> Thanks,
>> Jim Burke
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>     

-- 
Dan Putler
Sauder School of Business
University of British Columbia



More information about the R-sig-Geo mailing list