This function converts x
to a MatrixPrintForm
object via
matrix_form
, paginates it via paginate
, converts each
page to ASCII text via toString
, and emits the strings to file
,
separated by page_break
.
export_as_txt(
x,
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,
lineheight = 1L,
margins = c(top = 0.5, bottom = 0.5, left = 0.75, right = 0.75),
paginate = TRUE,
cpp = NA_integer_,
lpp = NA_integer_,
...,
hsep = default_hsep(),
indent_size = 2,
tf_wrap = paginate,
max_width = NULL,
colwidths = NULL,
min_siblings = 2,
nosplitin = character(),
rep_cols = num_rep_cols(x),
verbose = FALSE,
page_break = "\\s\\n"
)
if file
is NULL, the total paginated and then concatenated
string value, otherwise the file that was written.
ANY. The table-like object to export. Must have an
applicable matrix_form
method.
character(1) or NULL. If non-NULL, the path to write a
text file to containing the x
rendered as ASCII text,
character(1). Name of a page type. See
page_types
. Ignored when pg_width
and pg_height
are set directly.
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.
numeric(1). Page width in inches.
numeric(1). Page height in inches.
character(1). Name of a font family. An error will be thrown if the family named is not monospaced. Defaults to Courier.
numeric(1). Font size, defaults to 12.
numeric(1). Line height, defaults to 1.
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.
logical(1). Whether pagination should be performed,
defaults to TRUE
if page size is specified (including
the default).
numeric(1) or NULL. Width in characters per page. if NA (the default,
this is calculated automatically based on the specified page
size). NULL
indicates no horizontal pagination should occur.
numeric(1) or NULL. Lines per page. if NA (the default,
this is calculated automatically based on the specified page
size). NULL
indicates no vertical pagination should occur.
Passed to individual methods.
character(1). Characters to repeat to create header/body separator line.
numeric(1). Indent size in characters. Ignored
when x
is already a MatrixPrintForm object in favor of information
there.
logical(1). Should the texts for title, subtitle, and footnotes be wrapped?
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
.
numeric vector. Column widths (in characters) for use with vertical pagination.
numeric. Minimum sibling rows which must appear on either side of pagination row for a mid-subtable split to be valid. Defaults to 2.
character. List of names of sub-tables where page-breaks are not allowed, regardless of other considerations. Defaults to none.
numeric(1). Number of columns (not including row labels) to be repeated on every page. Defaults to 0
logical(1). Should additional informative messages about the search for
pagination breaks be shown. Defaults to FALSE
.
character(1). Page break symbol (defaults to
outputting "\n\s"
).
if x
has an num_rep_cols
method, the value
returned by it will be used for rep_cols
by default, if
not, 0 will be used.
If x
has an applicable do_mand_paginate
method, it will be invoked
during the pagination process.
export_as_txt(basic_matrix_form(mtcars), pg_height = 5, pg_width = 4)
Run the code above in your browser using DataLab