The help file (for rep
) says the following about the times argument:
an integer-valued 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. A
double vector is accepted, other inputs being coerced to an integer or double vector.
So it can be either of length 1 or the same length as the argument x, which is one in this case. If you need to repeat the 1 for 1, 2 and 3 times use
rep(1, sum(j))
Otherwise, please explain your goal.