I have been struggling with this for some time now and couldn\'t find any way of doing it, so I would be incredibly grateful if you could help! I am a novice in programming
I think the best approach is to change zones
to a more friendly format for what you're doing:
ZoneLookUp = lapply(split(zones, zones$Sentence), function(x) c(x$ZoneStart, x$ZoneEnd[nrow(x)]))
#$`1`
#[1] -8.86 -7.49 -5.88 -4.51 -2.90
Then you can easily look up each zone:
fixes$Zone = NULL
for(i in 1:nrow(fixes))
fixes$Zone[i] = cut(fixes$StartPosition[i], ZoneLookUp[[fixes$Sentence[i]]], labels=FALSE)
If performance is an issue, you can take a (only) slightly less simple approach using by
or data.table
with by.