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)
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)
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)
I got this, but is there a better way?
xvec <- rep(1:5, 5)
xvec <- sort(xvec)