If I have a vector like this:
x <- c(1:10)
and I under-index it, by asking for position 0 like this:
x[0]
I get a return type of integer(0) which I understand to be a zero length integer vector. That is fine. However, if I ask for an invalid index that is too high like this:
x[11]
The return is NA.
So my question is, why the difference? Why not get a zero length vector in both cases or an NA in both cases? Is there a reason or is this just a quirk of R?