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,] 1 4 7 >> [2,] 2 5 8 >> [3,] 3 6 9 >> > foo(grid, median(grid)) >> [1] c(2,2) https://stat.ethz.ch/pipermail/r-help/2013-May/353344.html > just use the argument arr.ind of ?which: > which(grid == median(grid), arr.ind = TRUE) > Note that it defaults to FALSE. and the result is a matrix. muito obrigado! ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.