radehabitathr

Sub-setting a spatial point data frame in R


I am trying to subset a spatial point data frame using the function subset as follows:

    data(puechabonsp)
    Chou.subset <- subset(puechabonsp,puechabonsp$relocs$Name=="Chou")

I was expecting to get all rows of the individual named "Chou" but instead, I got an empty list. Obviously I am doing it wrong and would apprentice some help.

Thanks! Idan


Solution

  • The puechabonsp variable contains 2 parts, a fixed map in the $map part and some tracks in the $relocs part. If you only want to know the locations where a specific animal is you can do this.

    Chou.subset <- puechabonsp$relocs[puechabonsp$relocs$Name=='Chou',]