This is a very basic question, but it's annoying me, so I'm asking.
I need a sequence of repeated numbers, i.e. 1 1 ... 1 2 2 ... 2 3 3 ... 3 etc. The way I implemented this was
which works, but is clumsy, and obviously doesn't scale well. How do I repeat the N integers M times each in sequence? I tried nesting seq() and rep() but that didn't quite do what I wanted. I can obviously write a for loop that will do it, but this also seems clumsy -- there should be an intrinsic way to do this!