How to get all numbers greater than x with positions?

V <- c(1,3,2,4,2,3,1); X <- 3; pos <-V[V == X]; 

pos 3 3 . I need all 3 positions;

I need 2 and 6 ; which are positions 3 in V .

+6
source share
1 answer

Use which

 pos <- which(V == 3) 

Not what you are asking for, but useful anyway: you can also use which.min and which.max to find the position of the minimum and maximum values โ€‹โ€‹of the array.

+16
source

Source: https://habr.com/ru/post/890340/


All Articles