1

a is a list.

a <- list(c(1:3),c(3:7),c(1:4))
> a
[[1]]
[1] 1 2 3

[[2]]
[1] 3 4 5 6 7

[[3]]
[1] 1 2 3 4

b is a series of numbers of indicators which contain some integers and integer(0).

I want to get the value of a[-b], it works when b is an integer such as 1.

b <- 1
a[-b]
[[1]]
[1] 3 4 5 6 7

[[2]]
[1] 1 2 3 4

But when it comes with integer(0), the result is not what I want.

b <- integer(0)
a[-b]
list()

I expect a[-b] would be a when the b is integer(0), since I need to do several loops. Thank you.

lightsnail
  • 788
  • 5
  • 20

0 Answers0