make_grouped_pagenums: Assign Page Numbers to Presorted Grouped Data
Description
Assigns sequential page numbers to elements of a vector, grouping by
unique values and allocating a specified number of rows per page.
The input vector must be presorted by group.
Usage
make_grouped_pagenums(var, rows)
Value
An integer vector of the same length as `var``, indicating
the assigned page number for each element.
Arguments
var
A vector of group labels, presorted so that identical
values are contiguous.
rows
Integer. The maximum number of rows per page.
Details
The function splits the input vector into groups, then assigns page numbers
within each group so that each page contains up to `rows`` items.
Page numbers increment sequentially across groups. If the input is not
presorted by group, the function will throw an error.