iteror.array {iterors}R Documentation

Iterate over an array or data frame by a specified dimension.

Description

Iterate over an array or data frame by a specified dimension.

Usage

## S3 method for class 'array'
iteror(
  obj,
  ...,
  by = c("cell", "row", "column"),
  chunkSize,
  chunks,
  recycle = FALSE,
  drop = FALSE,
  rowMajor = TRUE
)

## S3 method for class 'matrix'
iteror(
  obj,
  ...,
  by = c("cell", "row", "column"),
  chunkSize,
  chunks,
  recycle = FALSE,
  drop = FALSE,
  rowMajor = TRUE
)

## S3 method for class 'data.frame'
iteror(obj, ..., recycle = FALSE, chunkSize, chunks, by = c("column", "row"))

Arguments

obj

An object to iterate over.

...

Undocumented.

by

Which dimension to slice an array or data frame by. Can be "cell", "row", "column", or numeric dimensions.

chunkSize

The thickness of the slice to take along the specified dimension.

chunks

How many slices to take.

recycle

If TRUE, the iteror starts over on reaching the end.

drop

Whether to drop the array dimensions enumerated over.

rowMajor

If TRUE, will return slices in order with the first indices varying fastest (same as in i_enumerate).

Value

an iteror yielding from obj along the specified dimensions.

Examples

l <- iteror(letters, chunkSize=7)
as.list(l)

a <- array(1:8, c(2, 2, 2))

# iterate over all the slices
it <- iteror(a, by=3)
as.list(it)

# iterate over all the columns of each slice
it <- iteror(a, by=c(2, 3))
as.list(it)

# iterate over all the rows of each slice
it <- iteror(a, by=c(1, 3))
as.list(it)


[Package iterors version 1.0 Index]