Skip to contents

Batch a vector or list into a list of elements with a maximum size

Usage

batch_it(x, batch_size)

Arguments

x

A vector or list

batch_size

numeric. The size (length) of batches to create. Should be a single positive integer value (see Examples).

Examples

# ----
batch_it(letters, 6L)
#> [[1]]
#> [1] "a" "b" "c" "d" "e" "f"
#> 
#> [[2]]
#> [1] "g" "h" "i" "j" "k" "l"
#> 
#> [[3]]
#> [1] "m" "n" "o" "p" "q" "r"
#> 
#> [[4]]
#> [1] "s" "t" "u" "v" "w" "x"
#> 
#> [[5]]
#> [1] "y" "z"
#> 
batch_it(letters, 27L)
#> [[1]]
#>  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
#> [20] "t" "u" "v" "w" "x" "y" "z"
#>