[R] Index of item in matrix
John Janmaat
john.janmaat at acadiau.ca
Thu Apr 3 19:30:38 CEST 2003
Hello All,
Thanks,
John.
Peter Dalgaard BSA wrote:
> white.denis at epamail.epa.gov writes:
>
>
>>Try these:
>>
>>which.col <- function (mat, x) (which(mat==x)-1) %/% nrow(mat) + 1
>>which.row <- function (mat, x) (which(mat==x)-1) %% nrow(mat) + 1
>>
>>Knowing the R community, there may be already functions to do this.
>
>
> There is. Take another look at ?which.
>
--
--------------------------------------------------------------------------
Dr. John Janmaat
Department of Economics, Acadia University, Wolfville, NS, B4P 2R6
E-mail: jjanmaat at acadiau.ca Web: http://ace.acadiau.ca/~jjanmaat
Tel: 902-585-1461 Fax: 902-585-1070
More information about the R-help
mailing list