Learn R Programming

bit (version 4.5.0)

chunks: Function for chunked range index

Description

creates a sequence of range indexes using a syntax not completely unlike 'seq'

Usage

chunks(
  from = NULL,
  to = NULL,
  by = NULL,
  length.out = NULL,
  along.with = NULL,
  overlap = 0L,
  method = c("bbatch", "seq"),
  maxindex = NA
)

Value

returns a named list of ri objects representing chunks of subscripts

Arguments

from

the starting value of the sequence.

to

the (maximal) end value of the sequence.

by

increment of the sequence

length.out

desired length of the sequence.

along.with

take the length from the length of this argument.

overlap

number of values to overlap (will lower the starting value of the sequence, the first range becomes smaller

method

default 'bbatch' will try to balance the chunk size, see bbatch, 'seq' will create chunks like seq

maxindex

passed to ri

Author

Jens Oehlschlägel

See Also

generic chunk, ri, seq, bbatch

Examples

Run this code

  chunks(1, 100, by=30)
  chunks(1, 100, by=30, method="seq")
   if (FALSE) {
require(foreach)
m <- 10000
k <- 1000
n <- m*k
message("Four ways to loop from 1 to n. Slowest foreach to fastest chunk is 1700:1 
on a dual core notebook with 3GB RAM\n")
z <- 0L; 
print(k*system.time({it <- icount(m); foreach (i = it) %do% { z <- i; NULL }}))
z

z <- 0L
print(system.time({i <- 0L; while (i

Run the code above in your browser using DataLab