Compute per-group arg-max

argmax_g(col, first_indices)

Arguments

col

vector to max

first_indices

numeric index of first index in each group

Value

per-group arg-max

Examples

v <- c(2, 3, 1, 7, 5) fi <- c(1, 1, 3, 3, 3) argmax_g(v, fi)
#> [1] 2 2 4 4 4