Suppose I have a numeric vector v
v <- 1:5
I want to
rep
v[1]
by v[1]
times.
v[2]
by v[2]
times... and so on....
The desired output would be:
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
The following does not work. Got any ideas?
rep(v, each = function(x) v[x])
Many thanks in advance.