Ron*_*hah 6

类似于@Pratik的方法

您可以matchunique

match(unique(vec), vec)

#[1]  1  4  7 13
Run Code Online (Sandbox Code Playgroud)