Dear All,

Probably a very basic question, but can't seem to work my way around it.

I want to which row has the maximum value. But what if the row names do not correspond with the row numbers. In the example below, you'll see that the max of example is row 4, but the name of row 4 is "9". How do I get R to return "9" as value, instead of 4.

example <- matrix(c(0,0,0,1), 4, 1, dimnames=list(c("1", "3", "5", "9"), c("1")))
which.max(example)

[1] 4

Hope someone can help out.

Gijs Schumacher, MSc
PhD candidate

--------------------------------------
Department of Political Science
VU University Amsterdam

Contact:
Tel: +31(0)20 5986798
Fax: +31(0)20 5986820
Web: http://home.fsw.vu.nl/g.schumacher
Email: g.schumacher@vu.nl<mailto:g.schumacher@fsw.vu.nl>

Visiting address:
Metropolitan
Buitenveldertselaan 2
Room Z - 333

Mail:
De Boelelaan 1081
1081 HV Amsterdam
The Netherlands


	[[alternative HTML version deleted]]

