I have a simple question: how could I use which and which.max at the same time.
I would like to select the maximum epnum for the id == B13639J2 . I need to restore the row number because I need to make some changes manually to the variable.
So max epnum line id == 'B13639J2'
id epnum start 95528 B13639J2 1 0 95529 B13639J2 2 860 95530 B13639J2 3 1110 95531 B13639J2 4 1155 95532 B13639J2 5 1440
I was wondering how can I just do something like
dta[which(dta$id == 'B13639J2' & which.max(dta$epnum)), ]
Finally, I need to remove the spotted line.
Thanks.
Data
dta = structure(list(id = c("B13639J1", "B13639J1", "B13639J1", "B13639J1", "B13639J1", "B13639J1", "B13639J1", "B13639J1", "B13639J2", "B13639J2", "B13639J2", "B13639J2", "B13639J2"), epnum = c(4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5), start = c(420, 425, 435, 540, 570, 1000, 1310, 1325, 0, 860, 1110, 1155, 1440)), .Names = c("id", "epnum", "start"), row.names = 95520:95532, class = "data.frame")