Simple way to subset SpatialPolygonsDataFrame (i.e. delete polygons) by attribute in R
looks like you're overwriting the data, but not removing the polygons. If you want to cut down the dataset including both data and polygons, try e.g.
world.map <- world.map[world.map$AREA > 30000,]plot(world.map)
[[Edit 19 April, 2016]]That solution used to work, but @Bonnie reports otherwise for a newer R version (though perhaps the data has changed too?):world.map <- world.map[world.map@data$AREA > 30000, ]
Upvote @Bonnie's answer if that helped.
When I tried to do this in R 3.2.1, tim riffe's technique above did not work for me, although modifying it slightly fixed the problem. I found that I had to specifically reference the data slot as well before specifying the attribute to subset on, as below:
world.map <- world.map[world.map@data$AREA > 30000, ]plot(world.map)
Adding this as an alternative answer in case others come across the same issue.