The way of printing a zero-length vector(an integer one) is as follows:
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 approach you are using to identify which elements you want, but without further specific details, it is difficult to suggest an alternative strategy.