Generate a repeating sequence

后端 未结 6 1317
情深已故
情深已故 2021-01-14 01:27

I need to generate a vector of the following format using R:

1:10, 1:10, 11:20, 11:20, ... 121:130, 121:130

Is there an easier way than cre

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 01:41

    Alternatively, you could use a combination of rep and outer, such as:

    c(outer(1:10,rep(0:12,each=2),function(x,y)10*y+x))
    

提交回复
热议问题