Search code examples
rrepeatsequencesseq

R generate a sequence like 111222333444555666777.....505050


I want to generate a sequence just like :

c(rep(1,7),rep(2,7),rep(3,7),rep(4,7),rep(5,7),rep(6,7),rep(7,7)) 

But for large number instead of 7, say 100.

How can I do it without repeating until 100?

Thanks


Solution

  • Use the each= argument to rep:

    rep(1:7, each=7)