inst/examples/iarrayExample.R

library(itertools)
library(foreach)

n <- 10
x <- matrix(rnorm(n * n), n)

# Split matrix x into four submatrices and put them back
# together again
y <-
  foreach(a=iarray(x, c(1,2), chunks=2), .combine='cbind') %:%
    foreach(b=a, .combine='rbind') %do% {
      b
    }
print(identical(x, y))

Try the itertools package in your browser

Any scripts or data that you put into this service are public.

itertools documentation built on May 2, 2019, 6:16 p.m.