Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个不连续位置的值数据框,即前 100 个值是 1-100,但接下来的 100 个值是 3100-3200。我如何只返回他们的位置?
请注意,您已经定义了 201 个条目(3100:3200 的长度为 101)。
哪个位置?对于单个条目:
d <- data.frame(val=c(1:100,3100:3200)) which(d$val == 3199)
回报:
[1] 200
对于范围之一:
which(d$val >= 1 & d$val <= 100)