[R] [newbie] return index(s) for value?

2013-05-11 Thread Tom Roche
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]

Re: [R] [newbie] return index(s) for value?

2013-05-11 Thread Rui Barradas
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

Re: [R] [newbie] return index(s) for value?

2013-05-11 Thread Uwe Ligges
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

Re: [R] [newbie] return index(s) for value?

2013-05-11 Thread Tom Roche
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,]