Hi,
Let's say I have the following data:
a=matrix(c(1,2,4,4,2,1,1,2,4),nrow=3,byrow=T)
a
[,1] [,2] [,3]
[1,]124
[2,]421
[3,]124
What syntax should I use to get R to tell me the column that corresponds to
the maximum value for each row?
For my
apply(a, 1, which.max)
Apply the which.max() function to the matrix a row-wise (1)
Michael
On Tue, Jul 17, 2012 at 5:03 PM, Christopher Desjardins
cddesjard...@gmail.com wrote:
Hi,
Let's say I have the following data:
a=matrix(c(1,2,4,4,2,1,1,2,4),nrow=3,byrow=T)
a
[,1] [,2] [,3]
Hi,
Try,
apply(a,1,which.max)
[1] 3 1 3
A.K.
- Original Message -
From: Christopher Desjardins cddesjard...@gmail.com
To: r-help@r-project.org
Cc:
Sent: Tuesday, July 17, 2012 6:03 PM
Subject: [R] Finding the column with the maximum value by row
Hi,
Let's say I have the following
Hi,
You should be able to reach your goal using functions which and apply
On 7/17/2012 3:03 PM, Christopher Desjardins wrote:
Hi,
Let's say I have the following data:
a=matrix(c(1,2,4,4,2,1,1,2,4),nrow=3,byrow=T)
a
[,1] [,2] [,3]
[1,]124
[2,]421
[3,]1
4 matches
Mail list logo