cut_int: Cuts for dividing an integer into 'n' chunks

View source: R/number_tools.R

cut_intR Documentation

Cuts for dividing an integer into n chunks

Description

This function is intended for things like dividing large datasets into n chunks with a more-or-less equal number of rows in each chunk. Useful for generating batch files.

Usage

cut_int(int, chunks = NULL)

Arguments

int

(Integer) The number to divide.

chunks

(Integer) The number of chunks to divide it into.

Value

A tibble with four columns: chunk, which is the chunk's number, left, which is the start of each chunk, right, which is its end, and size, which is how many items are in the chunk.

Authors

Examples

cut_int(19.4e6, 9)

# # A tibble: 9 × 4
#   chunk     left    right    size
#   <int>    <dbl>    <dbl>   <dbl>
#       1        1  2155557 2155557
#       2  2155558  4311112 2155555
#       3  4311113  6466668 2155556
#       4  6466669  8622223 2155555
#       5  8622224 10777779 2155556
#       6 10777780 12933334 2155555
#       7 12933335 15088890 2155556
#       8 15088891 17244445 2155555
#       9 17244446 19400000 2155555


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.