emptyindices
is logical(0)
(logical vector of length = 0) and -emptyindices
becomes integer(0)
. So, you're querying the vector with indices of length = 0. You get back a length = 0 integer vector.
Probably you are looking for, for example, setdiff
:
v <- 6:10
idx1 <- c(1,3)
idx2 <- vector()
idx3 <- 1:5
v[setdiff(seq_along(v), idx1)]
# [1] 7 9 10
v[setdiff(seq_along(v), idx2)]
# [1] 6 7 8 9 10
v[setdiff(seq_along(v), idx3)]
# integer(0)