Skip to contents

[Experimental]

Pagination of a listing. This can be vertical for long listings with many rows or horizontal if there are many columns.

Usage

paginate_listing(
  lsting,
  page_type = "letter",
  font_family = "Courier",
  font_size = 12,
  lineheight = 1,
  landscape = FALSE,
  pg_width = NULL,
  pg_height = NULL,
  margins = c(top = 0.5, bottom = 0.5, left = 0.75, right = 0.75),
  lpp,
  cpp,
  colwidths = propose_column_widths(lsting),
  tf_wrap = FALSE,
  max_width = NULL,
  verbose = FALSE
)

pag_listing_indices(
  lsting,
  lpp = 15,
  colwidths = NULL,
  max_width = NULL,
  verbose = FALSE
)

Arguments

lsting

listing_df. The listing to paginate.

page_type

character(1). Name of a page type. See page_types. Ignored when pg_width and pg_height are set directly.

font_family

character(1). Name of a font family. An error will be thrown if the family named is not monospaced. Defaults to Courier.

font_size

numeric(1). Font size, defaults to 12.

lineheight

numeric(1). Line height, defaults to 1.

landscape

logical(1). Should the dimensions of page_type be inverted for landscape? Defaults to FALSE, ignored when pg_width and pg_height are set directly.

pg_width

numeric(1). Page width in inches.

pg_height

numeric(1). Page height in inches.

margins

numeric(4). Named numeric vector containing 'top', 'bottom', 'left', and 'right' margins in inches. Defaults to .5 inches for both vertical margins and .75 for both horizontal margins.

lpp

numeric(1) or NULL. Number of row lines (not counting titles and footers) to have per page. Standard is 70 while NULL disables vertical pagination.

cpp

numeric(1) or NULL. Width (in characters) of the pages for horizontal pagination. NULL (the default) indicates no horizontal pagination should be done.

colwidths

numeric vector. Column widths (in characters) for use with vertical pagination.

tf_wrap

logical(1). Should the texts for title, subtitle, and footnotes be wrapped?

max_width

integer(1), character(1) or NULL. Width that title and footer (including footnotes) materials should be word-wrapped to. If NULL, it is set to the current print width of the session (getOption("width")). If set to "auto", the width of the table (plus any table inset) is used. Ignored completely if tf_wrap is FALSE.

verbose

logical(1). Should additional informative messages about the search for pagination breaks be shown. Defaults to FALSE.

Value

A list of listings' objects that are meant to be on separated pages. For pag_tt_indices a list of paginated-groups of row-indices of lsting.

Examples

# Create a standard listing
dat <- ex_adae
lsting <- as_listing(dat[1:25, ], disp_cols = c("USUBJID", "AESOC", "RACE", "AETOXGR", "BMRKR1"))

mat <- matrix_form(lsting)

cat(toString(mat))
#> Study Identifier   Unique Subject Identifier   Primary System Organ Class             Race              Analysis Toxicity Grade   Continous Level Biomarker 1
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> AB12345              AB12345-BRA-1-id-134                 cl B                        WHITE                        3                   6.46299057842479      
#>                      AB12345-BRA-1-id-134                 cl D                        WHITE                        3                   6.46299057842479      
#>                      AB12345-BRA-1-id-134                 cl A                        WHITE                        2                   6.46299057842479      
#>                      AB12345-BRA-1-id-134                 cl A                        WHITE                        2                   6.46299057842479      
#>                      AB12345-BRA-1-id-141                 cl B                        WHITE                        3                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl D                        WHITE                        1                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl A                        WHITE                        1                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl A                        WHITE                        2                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl A                        WHITE                        1                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl D                        WHITE                        5                   7.51607612428241      
#>                      AB12345-BRA-1-id-236                 cl B              BLACK OR AFRICAN AMERICAN              5                   7.66300121077566      
#>                      AB12345-BRA-1-id-236                 cl B              BLACK OR AFRICAN AMERICAN              5                   7.66300121077566      
#>                      AB12345-BRA-1-id-236                 cl B              BLACK OR AFRICAN AMERICAN              5                   7.66300121077566      
#>                      AB12345-BRA-1-id-265                 cl C                        WHITE                        2                    10.323346349886      
#>                      AB12345-BRA-1-id-265                 cl D                        WHITE                        3                    10.323346349886      
#>                      AB12345-BRA-1-id-265                 cl D                        WHITE                        5                    10.323346349886      
#>                      AB12345-BRA-1-id-265                 cl C                        WHITE                        4                    10.323346349886      
#>                       AB12345-BRA-1-id-42                 cl C              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl D              BLACK OR AFRICAN AMERICAN              5                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl C              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl A              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl B              BLACK OR AFRICAN AMERICAN              1                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl A              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl B              BLACK OR AFRICAN AMERICAN              5                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl A              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      

# Vertical pagination
paginate_listing(lsting, lpp = 10)
#> [[1]]
#> Study Identifier   Unique Subject Identifier   Primary System Organ Class   Race    Analysis Toxicity Grade   Continous Level Biomarker 1
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> AB12345              AB12345-BRA-1-id-134                 cl B              WHITE              3                   6.46299057842479      
#>                      AB12345-BRA-1-id-134                 cl D              WHITE              3                   6.46299057842479      
#>                      AB12345-BRA-1-id-134                 cl A              WHITE              2                   6.46299057842479      
#>                      AB12345-BRA-1-id-134                 cl A              WHITE              2                   6.46299057842479      
#>                      AB12345-BRA-1-id-141                 cl B              WHITE              3                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl D              WHITE              1                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl A              WHITE              1                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl A              WHITE              2                   7.51607612428241      
#> 
#> [[2]]
#> Study Identifier   Unique Subject Identifier   Primary System Organ Class             Race              Analysis Toxicity Grade   Continous Level Biomarker 1
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> AB12345              AB12345-BRA-1-id-141                 cl A                        WHITE                        1                   7.51607612428241      
#>                      AB12345-BRA-1-id-141                 cl D                        WHITE                        5                   7.51607612428241      
#>                      AB12345-BRA-1-id-236                 cl B              BLACK OR AFRICAN AMERICAN              5                   7.66300121077566      
#>                      AB12345-BRA-1-id-236                 cl B              BLACK OR AFRICAN AMERICAN              5                   7.66300121077566      
#>                      AB12345-BRA-1-id-236                 cl B              BLACK OR AFRICAN AMERICAN              5                   7.66300121077566      
#>                      AB12345-BRA-1-id-265                 cl C                        WHITE                        2                    10.323346349886      
#>                      AB12345-BRA-1-id-265                 cl D                        WHITE                        3                    10.323346349886      
#>                      AB12345-BRA-1-id-265                 cl D                        WHITE                        5                    10.323346349886      
#> 
#> [[3]]
#> Study Identifier   Unique Subject Identifier   Primary System Organ Class             Race              Analysis Toxicity Grade   Continous Level Biomarker 1
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> AB12345              AB12345-BRA-1-id-265                 cl C                        WHITE                        4                    10.323346349886      
#>                       AB12345-BRA-1-id-42                 cl C              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl D              BLACK OR AFRICAN AMERICAN              5                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl C              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl A              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl B              BLACK OR AFRICAN AMERICAN              1                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl A              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#>                       AB12345-BRA-1-id-42                 cl B              BLACK OR AFRICAN AMERICAN              5                   2.26753940777848      
#> 
#> [[4]]
#> Study Identifier   Unique Subject Identifier   Primary System Organ Class             Race              Analysis Toxicity Grade   Continous Level Biomarker 1
#> —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
#> AB12345               AB12345-BRA-1-id-42                 cl A              BLACK OR AFRICAN AMERICAN              2                   2.26753940777848      
#> 

# Horizontal pagination
paginate_listing(lsting, cpp = 100, lpp = 40)
#> [[1]]
#> Study Identifier   Unique Subject Identifier   Primary System Organ Class
#> —————————————————————————————————————————————————————————————————————————
#> AB12345              AB12345-BRA-1-id-134                 cl B           
#>                      AB12345-BRA-1-id-134                 cl D           
#>                      AB12345-BRA-1-id-134                 cl A           
#>                      AB12345-BRA-1-id-134                 cl A           
#>                      AB12345-BRA-1-id-141                 cl B           
#>                      AB12345-BRA-1-id-141                 cl D           
#>                      AB12345-BRA-1-id-141                 cl A           
#>                      AB12345-BRA-1-id-141                 cl A           
#>                      AB12345-BRA-1-id-141                 cl A           
#>                      AB12345-BRA-1-id-141                 cl D           
#>                      AB12345-BRA-1-id-236                 cl B           
#>                      AB12345-BRA-1-id-236                 cl B           
#>                      AB12345-BRA-1-id-236                 cl B           
#>                      AB12345-BRA-1-id-265                 cl C           
#>                      AB12345-BRA-1-id-265                 cl D           
#>                      AB12345-BRA-1-id-265                 cl D           
#>                      AB12345-BRA-1-id-265                 cl C           
#>                       AB12345-BRA-1-id-42                 cl C           
#>                       AB12345-BRA-1-id-42                 cl D           
#>                       AB12345-BRA-1-id-42                 cl C           
#>                       AB12345-BRA-1-id-42                 cl A           
#>                       AB12345-BRA-1-id-42                 cl B           
#>                       AB12345-BRA-1-id-42                 cl A           
#>                       AB12345-BRA-1-id-42                 cl B           
#>                       AB12345-BRA-1-id-42                 cl A           
#> 
#> [[2]]
#> Study Identifier             Race              Analysis Toxicity Grade
#> ——————————————————————————————————————————————————————————————————————
#> AB12345                      WHITE                        3           
#>                              WHITE                        3           
#>                              WHITE                        2           
#>                              WHITE                        2           
#>                              WHITE                        3           
#>                              WHITE                        1           
#>                              WHITE                        1           
#>                              WHITE                        2           
#>                              WHITE                        1           
#>                              WHITE                        5           
#>                    BLACK OR AFRICAN AMERICAN              5           
#>                    BLACK OR AFRICAN AMERICAN              5           
#>                    BLACK OR AFRICAN AMERICAN              5           
#>                              WHITE                        2           
#>                              WHITE                        3           
#>                              WHITE                        5           
#>                              WHITE                        4           
#>                    BLACK OR AFRICAN AMERICAN              2           
#>                    BLACK OR AFRICAN AMERICAN              5           
#>                    BLACK OR AFRICAN AMERICAN              2           
#>                    BLACK OR AFRICAN AMERICAN              2           
#>                    BLACK OR AFRICAN AMERICAN              1           
#>                    BLACK OR AFRICAN AMERICAN              2           
#>                    BLACK OR AFRICAN AMERICAN              5           
#>                    BLACK OR AFRICAN AMERICAN              2           
#> 
#> [[3]]
#> Study Identifier   Continous Level Biomarker 1
#> ——————————————————————————————————————————————
#> AB12345                 6.46299057842479      
#>                         6.46299057842479      
#>                         6.46299057842479      
#>                         6.46299057842479      
#>                         7.51607612428241      
#>                         7.51607612428241      
#>                         7.51607612428241      
#>                         7.51607612428241      
#>                         7.51607612428241      
#>                         7.51607612428241      
#>                         7.66300121077566      
#>                         7.66300121077566      
#>                         7.66300121077566      
#>                          10.323346349886      
#>                          10.323346349886      
#>                          10.323346349886      
#>                          10.323346349886      
#>                         2.26753940777848      
#>                         2.26753940777848      
#>                         2.26753940777848      
#>                         2.26753940777848      
#>                         2.26753940777848      
#>                         2.26753940777848      
#>                         2.26753940777848      
#>                         2.26753940777848      
#> 

# Use `verbose = TRUE` to display more descriptive warnings or errors
# paginate_listing(lsting, cpp = 80, lpp = 40, verbose = TRUE)