balt_orig <- readShapePoints(system.file("shapes/baltim.shp", package="maptools")[1])
plot(balt_orig)
balt_cheap <- balt_orig[balt_orig$PRICE < 40,]
file <- tempfile("")
write.pointShape(coordinates=coordinates(balt_cheap),
df=as(balt_cheap, "data.frame"), file)
getinfo.shape(paste(file, ".shp", sep=""))
balt_new <- readShapePoints(paste(file, ".shp", sep=""))
plot(balt_new, col="red", pch=16, add=TRUE)
Run the code above in your browser using DataLab