Learn R Programming

rlistings (version 0.2.9)

paginate_listing: Paginate listings

Description

[Experimental]

Pagination of a listing. This can be vertical for long listings with many rows and/or horizontal if there are many columns. This function is a wrapper of formatters::paginate_to_mpfs() and it is mainly meant for exploration and testing.

Usage

paginate_listing(
  lsting,
  page_type = "letter",
  font_family = "Courier",
  font_size = 8,
  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 = NA_integer_,
  cpp = NA_integer_,
  colwidths = NULL,
  tf_wrap = !is.null(max_width),
  rep_cols = NULL,
  max_width = NULL,
  col_gap = 3,
  fontspec = font_spec(font_family, font_size, lineheight),
  verbose = FALSE,
  print_pages = TRUE
)

Value

A list of listing_df objects where each list element corresponds to a separate page.

Arguments

lsting

(listing_df or list)
the listing or list of listings to paginate.

page_type

(string)
name of a page type. See page_types. Ignored when pg_width and pg_height are set directly.

font_family

(string)
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

(flag)
whether the dimensions of page_type should be inverted for landscape orientation. 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 "bottom", "left", "top", 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 rows/lines (excluding titles and footers) to include 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 of column widths (in characters) for use in vertical pagination.

tf_wrap

(flag)
whether the text for title, subtitles, and footnotes should be wrapped.

rep_cols

(numeric(1))
number of columns (not including row labels) to be repeated on every page. Defaults to 0.

max_width

(integer(1), string 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. Parameter is ignored if tf_wrap = FALSE.

col_gap

(numeric(1))
width of gap between columns, in same units as extent in pagdf (spaces under a particular font specification).

fontspec

(font_spec)
a font_spec object specifying the font information to use for calculating string widths and heights, as returned by font_spec().

verbose

(flag)
whether additional informative messages about the search for pagination breaks should be shown. Defaults to FALSE.

print_pages

(flag)
whether the paginated listing should be printed to the console (cat(toString(x))).

Examples

Run this code
dat <- ex_adae
lsting <- as_listing(dat[1:25, ], disp_cols = c("USUBJID", "AESOC", "RACE", "AETOXGR", "BMRKR1"))
mat <- matrix_form(lsting)
cat(toString(mat))

paginate_listing(lsting, lpp = 10)

paginate_listing(lsting, cpp = 100, lpp = 40)

paginate_listing(lsting, cpp = 80, lpp = 40, verbose = TRUE)

Run the code above in your browser using DataLab