如何使用位置获得大于x的所有数字?

Rob*_*bin 7 r

V <- c(1,3,2,4,2,3,1);

X <- 3;
pos <-V[V == X];
Run Code Online (Sandbox Code Playgroud)

pos3 3.我需要的是所有3个的位置;

我需要26; 其是的位置3V.

nic*_*ico 16

使用 which

pos <- which(V == 3)
Run Code Online (Sandbox Code Playgroud)

不是你要求的,但无论如何有用:你也可以使用which.minwhich.max找到数组最小值和最大值的位置.

  • 请注意`which.min`和`which,max` tho,它们只返回第一个最小或最大元素. (2认同)