getListing: Format or create flextable for listings.

View source: R/flextable-getListing.R

getListingR Documentation

Format or create flextable for listings.

Description

Flextable version >= 0.4.7 and pandoc >= 2.4 is required to included such table in a Rmarkdown document.

Usage

getListing(
  data,
  ft,
  border = TRUE,
  highlight = integer(),
  bgVar = NULL,
  fontname = switch(style, report = "Times", presentation = "Tahoma"),
  fontsize = switch(style, report = 8, presentation = 10),
  landscape = (style == "presentation"),
  style = "report",
  margin = 1,
  adjustWidth = TRUE,
  colorTable = getColorPaletteTable(style = style),
  align = TRUE,
  title = NULL,
  pageDim = NULL,
  includeRownames = TRUE
)

Arguments

data

data.frame with data used in table.

ft

Corresponding flextable.

border

Logical, if TRUE add a border.

highlight

Integer vector with index(ices) of column(s) to highlight (only applies for style: 'presentation'). 0 for rownames (if present). Colors for:

  • highlighted columns is specified in colorTable["headerBackgroundHighlight"]

  • non highlighted columns is specified in colorTable["headerBackground"]

bgVar

String with the column of the data used for alternating the body background colors of the table.

fontname

String with font name, 'Times' by default.

fontsize

Integer with font size, 8 by default.

landscape

Logical, if TRUE the table is presented in landscape format.
By default: TRUE for style: 'report', FALSE for style: 'presentation'.

style

String with table style, either 'report' (by default, a4 format) or 'presentation'

margin

Margin in the document in inches, 1 by default.

adjustWidth

Logical, if TRUE adjust column widths, to comply to specification of landscape, margin and pageDim (only set to FALSE if e.g. table dimensions are pre-set with the specified ft).

colorTable

Named character vector with color for the table, see output of getColorPaletteTable for required elements.

align

Logical, if TRUE (by default), default alignment is set ('center' in all table).

title

Character vector with title(s) for the table. Set to NULL (by default) if no title should be included. Only available if ft is not specified.

pageDim

(optional) Numeric vector of length 2 with page width and height in inches in portrait format, in case page dimensions differ from the default implemented report/presentation. These dimensions should include the margins.

includeRownames

Logical, if TRUE (by default) rownames are included in the flextable object.

Value

flextable with style.

Examples

# style: report or presentation
getListing(data = head(mtcars), style = "report")
getListing(data = head(mtcars), style = "presentation")
# remove rownames (included by default)
getListing(data = head(mtcars), style = "presentation", includeRownames = FALSE)
# highlight:
#  all columns
getListing(data = head(mtcars), style = "presentation", highlight = seq_along(mtcars))
# rownames
getListing(data = head(mtcars), style = "presentation", highlight = 0)
# specific columns
getListing(data = head(mtcars), style = "presentation", highlight = c(2, 4))

inTextSummaryTable documentation built on June 22, 2024, 9:24 a.m.