Skip to content
Prev 293424 / 398503 Next

Identifying the particular X or Y in a sorted list

Hello,


Shankar Lanke wrote
If I understand it correctly, this should do it.

x <- read.table(text="
A B C D
1 14 10 4
2 12 7 5
3 11 15 -4
4 8 3 5
5 1 8 -7
", header=TRUE)

which(x$D == max(x$D))
x$A[ which(x$D == max(x$D)) ]

Or you can save the values of the which() function and use them when needed.

Hope this helps,
Rui Barradas



--
View this message in context: http://r.789695.n4.nabble.com/Identifying-the-particular-X-or-Y-in-a-sorted-list-tp4605124p4606062.html
Sent from the R help mailing list archive at Nabble.com.