Simple questions, but I can\'t find an answer.
I have a vector
a<-c(5,6,7)
how can I get back the indices for all elements in my vec
This is the purpose served by the seq_along function:
seq_along
seq_along(a) [1] 1 2 3 > cbind( seq_along(a), a) a [1,] "1" "a" [2,] "2" "b" [3,] "3" "c" > data.frame( sq = seq_along(a), a) sq a 1 1 a 2 2 b 3 3 c