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
範囲の 1 つの場合:
which(d$val >= 1 & d$val <= 100)