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

I knew using sum(j) would work.
But not understanding my mistake while trying the other way.

My goal is to repeat any number with times=the call cell of a column.
I tried the following and got new error:

res=NULL
for (i in 1:3){res[i:d1[i,2]]=rep(1,d1[i,2])}
Warning message:
In res[i:d1[i, 2]] <- rep(1, d1[i, 2]) :
number of items to replace is not a multiple of replacement length

After the first run of the for loop, res is a vector with two elements, both of which are equal to 1. On the second run of the for loop, i = 2 and d1[i,2] is equal to 2, so rep(1, d1[i,2]) returns the equivalent of c(1,1). The statement in the for loop is then
res[2:2] <- c(1,1). You are try to assign a vector with two elements to a single element of res. That causes the Warning.