R's way of printing a zero length vector(an integer one). So you could test for length 0
length(a)
[1] 0
I suggest you not to use which, and try using the above method
It might be worth rethinking the strategy you are using to identify which elements you want, but without further specific details it is difficult to suggest an alternative strategy.