Is there a function 'foo' such that, given an array and a value, iff
the value is present in the array, it returns the index(s) of the
value? E.g.,
matrix(1:9, nrow=3) - grid
grid
[,1] [,2] [,3]
[1,]147
[2,]258
[3,]369
foo(grid, median(grid))
[1]
Hello,
To that effect, just use the argument arr.ind of ?which:
which(grid == median(grid), arr.ind = TRUE)
Note that it defaults to FALSE.
Hope this helps,
Rui Barradas
Em 11-05-2013 23:35, Tom Roche escreveu:
Is there a function 'foo' such that, given an array and a value, iff
the
On 12.05.2013 00:35, Tom Roche wrote:
Is there a function 'foo' such that, given an array and a value, iff
the value is present in the array, it returns the index(s) of the
value? E.g.,
matrix(1:9, nrow=3) - grid
grid
[,1] [,2] [,3]
[1,]147
[2,]258
[3,]3
https://stat.ethz.ch/pipermail/r-help/2013-May/353343.html
Is there a function 'foo' such that, given an array and a value,
iff the value is present in the array, it returns the index(s) of
the value? E.g.,
matrix(1:9, nrow=3) - grid
grid
[,1] [,2] [,3]
[1,]147
[2,]
4 matches
Mail list logo