Re: [R] returning the largest element in an array/matrix?

2006-03-07 Thread Petr Pikal
Subject:[R] returning the largest element in an array/matrix? Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return the row and column indices. But which.max only works for vector... Is there any convinient way to solve

Re: [R] returning the largest element in an array/matrix?

2006-03-07 Thread Henrik Bengtsson
] To: R-help@stat.math.ethz.ch Subject:[R] returning the largest element in an array/matrix? Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return the row and column indices. But which.max only

Re: [R] returning the largest element in an array/matrix?

2006-03-07 Thread Michael
From: Michael [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject:[R] returning the largest element in an array/matrix? Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return

Re: [R] returning the largest element in an array/matrix?

2006-03-07 Thread Gabor Grothendieck
:[R] returning the largest element in an array/matrix? Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return the row and column indices. But which.max only works for vector... Is there any convinient way to solve

[R] returning the largest element in an array/matrix?

2006-03-06 Thread Michael
Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return the row and column indices. But which.max only works for vector... Is there any convinient way to solve this problem? Thanks a lot! [[alternative HTML version deleted]]

Re: [R] returning the largest element in an array/matrix?

2006-03-06 Thread Jacques VESLOT
indcol - rep(1:ncol(mat), each=nrow(mat))[which.max(mat)] indrow - rep(1:nrow(mat), ncol(mat))[which.max(mat)] indrow - which(apply(mat==max(mat),1,sum)!=0) indcol - which(apply(mat==max(mat),2,sum)!=0) Michael a écrit : Hi all, I want to use which.max to identify the maximum in a 2D

Re: [R] returning the largest element in an array/matrix?

2006-03-06 Thread Michael
Any more convinient methods? On 3/6/06, Jacques VESLOT [EMAIL PROTECTED] wrote: indcol - rep(1:ncol(mat), each=nrow(mat))[which.max(mat)] indrow - rep(1:nrow(mat), ncol(mat))[which.max(mat)] indrow - which(apply(mat==max(mat),1,sum)!=0) indcol - which(apply(mat==max(mat),2,sum)!=0)

Re: [R] returning the largest element in an array/matrix?

2006-03-06 Thread Gabor Grothendieck
Try this: m - diag(4-abs(-4:4)) # test matrix wm - which.max(m) c(row(m)[wm], col(m)[wm]) # c(5,5) On 3/6/06, Michael [EMAIL PROTECTED] wrote: Hi all, I want to use which.max to identify the maximum in a 2D array/matrix and I want argmin and return the row and column indices. But