in my data
data=structure(list(v1 = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), 
    v2 = c(1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), x = c(10L, 
    1L, 2L, 3L, 4L, 3L, 2L, 30L, 3L, 5L)), .Names = c("v1", "v2", 
"x"), class = "data.frame", row.names = c(NA, -10L))
There are 3 variables. I need to get only those lines in relation to which X, has the max value. For example. Take First category of v1 and look in relation to which category v2 x has max value It is
v1=1 and v2=1 x=10
Take second category of v1 and  look in relation to which category v2 x has max value
It is v1=2 ,v2=3 x=30
so desired output
v1  v2  x
1   1   10
2   3   30
How to do it?
 
     
    