0

Im interested in generating a list with a sequencing of numbers like in this fashion:

list(1:3, 4:6, 7:9)

I have tried variations of using list and seq without luck and using repetition like rep(list(1:3), 3) gets me the right format but without the advancing sequencing so I'm at a loss to what probably is a really simple problem. Thanks in advance.

Krl74
  • 11
  • 1

1 Answers1

1

We can use gl to create a grouping variable for splitting the vector

split(x, as.integer(gl(length(x), 3, length(x))))

data

x <- 1:9
akrun
  • 789,025
  • 32
  • 460
  • 575