Learn R Programming

rlistings (version 0.2.1)

export_as_txt: Export as plain text with page break symbol

Description

Export as plain text with page break symbol

Usage

export_as_txt(
  lst,
  file = NULL,
  page_type = NULL,
  landscape = FALSE,
  pg_width = page_dim(page_type)[if (landscape) 2 else 1],
  pg_height = page_dim(page_type)[if (landscape) 1 else 2],
  font_family = "Courier",
  font_size = 8,
  paginate = .need_pag(page_type, pg_width, pg_height, lpp, cpp),
  cpp = NULL,
  lpp = NULL,
  ...,
  page_break = "\\s\\n",
  hsep = default_hsep(),
  indent_size = 2,
  tf_wrap = paginate,
  max_width = cpp,
  colwidths = propose_column_widths(matrix_form(lst, TRUE))
)

Value

file (this function is called for the side effect of writing the file.

Arguments

lst

Listing object

file

character(1). File to write.

page_type

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

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.

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 8.

paginate

logical(1). Should lst be paginated before writing the file. Defaults to TRUE if any sort of page dimension is specified.

cpp

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

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.

...

Passed directly to paginate_listing

page_break

character(1). Page break symbol (defaults to outputting "\s").

hsep

character(1). Characters to repeat to create header/body separator line.

indent_size

numeric(1). Indent size in characters. Ignored when x is already a MatrixPrintForm object in favor of information there.

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.

colwidths

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

Examples

Run this code

dat <- ex_adae
lsting <- as_listing(dat[1:25, ], key_cols = c("USUBJID", "AESOC")) %>%
  add_listing_col("AETOXGR") %>%
  add_listing_col("BMRKR1", format = "xx.x") %>%
  add_listing_col("AESER / AREL", fun = function(df) paste(df$AESER, df$AREL, sep = " / "))
main_title(lsting) <- "this is some title"
main_footer(lsting) <- "this is some footer"
cat(export_as_txt(lsting, file = NULL, paginate = TRUE))

Run the code above in your browser using DataLab