rep() with each equals a vector

rep(1:5, vect1)

If you have questions about how to work functions in R, try

?function

where “function” is whatever function you want to know about. From ?rep you would have read:

‘times’ A integer vector giving the (non-negative) number of times to repeat
each element if of length length(x), or to repeat the whole vector if
of length 1. Negative or NA values are an error.

Leave a Comment