This affects the output when
x
is a matrix, array, or object with names.
If
FALSE then return the
vector indices of the
TRUE
values in
as.vector(x).
If
TRUE and
x
is a matrix or array then return the row, column, etc. indices
of the
TRUE. These will be returned
in a matrix with one column for each dimension of the input array.
If
TRUE and
x
has names, then the appropriate subset of those names will be attached
to the output vector.
VALUE:
Returns the positions of the
TRUE values in
x.
SEE ALSO:
EXAMPLES:
x <- c(10,20,30,NA,40)
which(x>=30)
# expect to get [1] 3 5
x[which(x>=30)]
# expect to get [1] 30 40
which( cbind(c(T,F,F), c(F,F,T)), arr.ind=T)
# expect to get
# row col
# [1,] 1 1
# [2,] 3 2