Search code examples
rrep

using rep function to create repetition multiple times


I did the following:

season<-rep(c("aut","win","sum"), each=520)

When I do this, I get aut repeated 520 times followed by win repeated 520 times and then sum repeated 520 times. I want to do this 16 times i.e aut 520, win 520, sum 520 and then again aut 520, win 520, sum 520 and again......16 times. Could anyone advise me how to do this?

Thanks


Solution

  • With one expression you can use both the times and each arguments:

    rep(c("aut","win","sum"), each=520, times=16)