make_grouped_pagenums | R Documentation |
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.
make_grouped_pagenums(var, rows)
var |
A vector of group labels, presorted so that identical values are contiguous. |
rows |
Integer. The maximum number of rows per page. |
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.
An integer vector of the same length as 'var“, indicating the assigned page number for each element.
library(dplyr)
iris |>
mutate(
page = make_grouped_pagenums(Species, 5)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.