I have a vector and I want to get the location (indices) of the first occurrence of each unique value.
vec <- c(4,4,4,3,3,3,5,4,5,4,3,3,56)
(pos <- ?????????)
I want in return
# 1 4 7 13
I.e. 1
is the first index of 4, 4
is the first index of 3, and so on.