1

I have a data frame with 25 values, and I'd like to repeat 1:3, each value 10 times (so first 10 values have 1, next 10 have 2, next 5 have 3).

But, since my 3rd set of values is not a full 10, I am getting the error that my replacement has more rows than my data. I'm wondering why length handles this with no problem, but times doesn't.

Is the answer as simple as I think it is?

df$y <- rep(1:3, times = 10, length = nrow(df))
zx8754
  • 52,746
  • 12
  • 114
  • 209
coderX
  • 424
  • 5
  • 16

0 Answers0