Learn R Programming

lvec (version 0.2.5)

chunk: Generate a number of index ranges from a vector

Description

The ranges have a maximum length.

Usage

chunk(x, ...)

# S3 method for lvec chunk(x, chunk_size = 1e+06, ...)

# S3 method for default chunk(x, chunk_size = NULL, ...)

# S3 method for data.frame chunk(x, chunk_size = NULL, ...)

Arguments

x

an object for which the index ranges should be calculated. Should support the length method. For example, an lvec or a regular R vector.

...

ignored; used to pass additional arguments to other methods.

chunk_size

a numeric vector of length 1 giving the maximum length of the chunks.

Details

The default chunk size can be changes by setting the option 'chunk_size', (`options(chunk_size = <new default chunk size>)`).

Implementations of chunk for data frames and regular vectors are provided to make it easier to write code that works on both lvec objects and regular R objects.