📜  R 迭代器 ichunk - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:57.883000             🧑  作者: Mango

代码示例1
# Split the vector 1:10 into "chunks" with a maximum length of three
it <- ihasNext(ichunk(1:10, 3))
while (hasNext(it)) {
  print(unlist(nextElem(it)))
}

# Same as previous, but return integer vectors rather than lists
it <- ihasNext(ichunk(1:10, 3, mode='integer'))
while (hasNext(it)) {
  print(nextElem(it))
}