Skip to main content
2 of 2
added 143 characters in body
Spacedman
  • 66.5k
  • 6
  • 83
  • 121

You can subset the @data slot which is a plain data frame, but its not always a good idea to access members of an object class via slots, in which case you can convert to a plain data frame with as.data.frame, which drops the geometry and gives back a plain data frame:

bar_vector = as.data.frame(spfoo)[,"bar"]

One advantage of using as.data.frame instead of the slot is that this will also work if your spatial object is one of the new sf classes.

Spacedman
  • 66.5k
  • 6
  • 83
  • 121