Dear R users,

I wonder how I can use R to identify the max value of each row, the column
number column name:

For example:

a <- data.frame(x = rnorm(4), y = rnorm(4), z = rnorm(4))

> a
           x          y          z
1 -0.7289964  0.2194702 -2.4674780
2  1.0889353  0.3167629 -0.9208548
3 -0.6374692 -1.7249049  0.6567313
4 -0.1348642  0.4507473 -1.7309010

In this data frame, I compare y and z only.

What I need:

            x                     y                     z
 max                 max.col.num         max.col.name
1 -0.7289964  0.2194702 -2.4674780         0.2194702               2
                     y
2  1.0889353  0.3167629 -0.9208548         0.3167629               2
                     y
3 -0.6374692 -1.7249049  0.6567313         0.6567313               3
                    z
4 -0.1348642  0.4507473 -1.7309010         0.4507473               2
                    y


Any suggestion will be greatly appreciated!

Thank you!

Gary

	[[alternative HTML version deleted]]

