Learn R Programming

rtables (version 0.6.0)

export_as_txt: Export as plain text with page break symbol

Description

Export as plain text with page break symbol

Usage

export_as_txt(
  tt,
  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(tt, TRUE))
)

Value

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

Arguments

tt

TableTree (or related class). A TableTree object representing a populated table.

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

paginate

logical(1). Should tt 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. Maximum lines per page including (re)printed header and context rows

...

Passed directly to paginate_table

page_break

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

hsep

character(1). Set of character(s) to be repeated as the separator between the header and body of the table when rendered as text. Defaults to a connected horizontal line (unicode 2014) in locals that use a UTF charset, and to - elsewhere (with a once per session warning).

indent_size

numeric(1). Number of spaces to use per indent level. Defaults to 2

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 for use with vertical pagination.

See Also

export_as_pdf()

Examples

Run this code

lyt <- basic_table() %>%
  split_cols_by("ARM") %>%
  analyze(c("AGE", "BMRKR2", "COUNTRY"))

tbl <- build_table(lyt, ex_adsl)

cat(export_as_txt(tbl, file = NULL, paginate = TRUE, lpp = 8))

if (FALSE) {
tf <- tempfile(fileext = ".txt")
export_as_txt(tbl, file = tf)
system2("cat", tf)
}

Run the code above in your browser using DataLab