问题
Suppose I know the min and max id, what I need is to have all ids between the min and max ones. Suppose id<-c(1:20) now min=1 and max=20 which function in R show the all values between these two numbers?
回答1:
You can use sets algebra:
id <- c(1:20)
setdiff(id, range(id))
#[1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Also you can do:
id[!(id %in% range(id))]
or:
id[!(id %in% c(max(id), min(id)))]
来源:https://stackoverflow.com/questions/43746935/all-values-between-min-and-max