All values between min and max

一笑奈何 提交于 2021-02-10 06:52:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!