0

I want to count upwards but have each number repeated, lets say 5 times.

example:

final_answer <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3)
user2795569
  • 343
  • 2
  • 9

2 Answers2

1
rep(1:3, each = 5)
#>  [1] 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3

Created on 2021-03-16 by the reprex package (v1.0.0)

Yuriy Saraykin
  • 8,390
  • 1
  • 7
  • 14
0

I got this, but is there a better way?

xvec <- rep(1:5, 5)
xvec <- sort(xvec)
user2795569
  • 343
  • 2
  • 9