I have two shapefiles with polygons (say S1 and S2). Some of the polygons are overlapping in the two shapefiles but not perfectly. In addition some polygons from S1 are touching polygons from S2. I need to join the two shapefile but if there is a polygon from S1 overlapping polygon from S2 keep the polygon as is from S1 and delete that same polygon from S2. if only touching delete the overlapping area.
Is there a way to do this in R?