I have a frequency table:
# a b
# x 1
# y 2
# z 3
and I want to create a vector [x, y, y, z, z, z] based on the counts in b.
What's the most efficient way of doing this?
Thanks!
Use the rep
function. I am not aware of any other method that is quicker than this.
a = c("x","y", "z")
b = c(1,2,3)
output <- rep(a,b)