Usually listings will be paginated with colwidths set. In this case the colwidths will be the same for all pages, even when split_into_pages_by_var is breaking alisting up into a list prior to pagination.
In the corner case they are not, however, we can get listings that have different column widths for the different "pagination sections" it is split into. In extreme cases this can result in column pagination being entirely different between sections of the listing:
mtcars2 <- mtcars
carspl <- strsplit(row.names(mtcars2), " ")
mtcars2$brand <- sapply(carspl, function(x) x[1])
mtcars2$model <- sapply(carspl, function(x) paste(x[-1], collapse = " "))
mtcars3 <- subset(mtcars2, brand %in% c("Dodge", "AMC", "Merc", "Datsun"))
lsting <- as_listing(mtcars3, key_cols = c("am", "cyl"),
disp_cols = c("model", "hp", "gear", "disp"))
topag <- split_into_pages_by_var(lsting, "brand")
res <- paginate_listing(topag, cpp = 26)
gives us
--- Page 1/10 ---
brand: Merc
———————————————————————
am cyl model hp
———————————————————————
0 4 240D 62
230 95
6 280 123
280C 123
8 450SE 180
450SL 180
450SLC 180
--- Page 2/10 ---
brand: Merc
———————————————————————
am cyl gear disp
———————————————————————
0 4 4 146.7
4 140.8
6 4 167.6
4 167.6
8 3 275.8
3 275.8
3 275.8
--- Page 3/10 ---
brand: Dodge
—————————————————————
am cyl model
—————————————————————
0 8 Challenger
--- Page 4/10 ---
brand: Dodge
—————————————————————
am cyl hp gear
—————————————————————
0 8 150 3
--- Page 5/10 ---
brand: Dodge
———————————————
am cyl disp
———————————————
0 8 318
--- Page 6/10 ---
brand: AMC
——————————————————
am cyl model
——————————————————
0 8 Javelin
--- Page 7/10 ---
brand: AMC
—————————————————————
am cyl hp gear
—————————————————————
0 8 150 3
--- Page 8/10 ---
brand: AMC
———————————————
am cyl disp
———————————————
0 8 304
--- Page 9/10 ---
brand: Datsun
—————————————————————
am cyl model hp
—————————————————————
1 4 710 93
--- Page 10/10 ---
brand: Datsun
——————————————————————
am cyl gear disp
——————————————————————
1 4 4 108
The Merc and Datsun sections are each separated into two pages, while the Dodge and AMC sections are separated into three, despite them being parts of the same listing.
Breaking the listing into parts after pagination begins (ie after paginate_listing is called) would not have this issue because the overall colwidths could be calculated before the split and thus apply to all parts. That is the intention of allowing packages to define do_forced_paginate, which does exactly this (see the page_by behavior for rtables).
Usually listings will be paginated with colwidths set. In this case the colwidths will be the same for all pages, even when
split_into_pages_by_varis breaking alisting up into a list prior to pagination.In the corner case they are not, however, we can get listings that have different column widths for the different "pagination sections" it is split into. In extreme cases this can result in column pagination being entirely different between sections of the listing:
gives us
The
MercandDatsunsections are each separated into two pages, while theDodgeandAMCsections are separated into three, despite them being parts of the same listing.Breaking the listing into parts after pagination begins (ie after
paginate_listingis called) would not have this issue because the overall colwidths could be calculated before the split and thus apply to all parts. That is the intention of allowing packages to definedo_forced_paginate, which does exactly this (see thepage_bybehavior for rtables).