How can I select the shapefile feature there is, "D3" in "New.Code" columns using sf packages in R

enter image description here

Here is the attribute table of my shapefile: enter image description here

1 Answer 1


Select rows like its a data frame, and use st_write to make a shapefile:

st_write(thing[thing$New.Code=="D3",], "justD3.shp")

If you are struggling with this, you should probably read a good introduction to R and spatial data in R, to get familiar with the basics.

  • Thankyou so much for the answer May 31 at 4:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.