formatSummaryStatisticsTableFlextable {inTextSummaryTable}R Documentation

Merge nested rows of a summary table for a format compatible with flextable

Description

Merge nested rows of a summary table for a format compatible with flextable

Usage

formatSummaryStatisticsTableFlextable(
  summaryTable,
  rowVar = getAttribute(summaryTable, "rowVar"),
  rowVarInSepCol = NULL,
  rowVarTotalInclude = getAttribute(summaryTable, "rowVarTotalInclude"),
  statsLayout = "row",
  statsVar = getAttribute(summaryTable, "statsVar"),
  statsLabInclude = getAttribute(summaryTable, "statsLabInclude", default =
    length(statsVar) > 1),
  rowVarLab = getAttribute(summaryTable, "rowVarLab", default = getLabelVar(rowVar,
    labelVars = labelVars)),
  rowVarTotalInSepRow = NULL,
  vline = c("none", "auto"),
  hline = c("none", "auto"),
  rowAutoMerge = TRUE,
  rowVarFormat = NULL,
  rowTotalLab = NULL,
  labelVars = NULL
)

Arguments

summaryTable

A summaryTable object.

rowVar

Character vector with variable(s) to be included in the rows. If multiple variables are specified, the variables should be sorted in hierarchical order (e.g. body system class before adverse event term) and are nested in the table.

rowVarInSepCol

Character vector with rowVar that should be included in separated columns. By default (NULL), all row variables are nested in the first column of the table.
To include the groups within a var variable in a separated column, set: rowVarInSepCol == 'variableGroup'.

rowVarTotalInclude

Character vector with rowVar for which the total should be reported.
If the higher row variable is specified, the total across all rows is reported.
For the export, these variable(s) are formatted as factor with 'Total' as the first level.

statsLayout

String with layout for the statistics names (in case more than one statistic is included), among:

  • row (by default for 'flextable' output):
    All statistics are included in different rows in the first column of the table (after the row variable(s))

  • 'col' (by default for 'DT' output):
    Statistics are included in separated columns (last row of the header).
    This option is not compatible with categorical variable(s).

  • 'rowInSepCol':
    Statistics are included in different rows, but in a separated column than the rowVar variable(s)

statsVar

Character vector with columns of summaryTable with statistic variables. For the export: if not specified, all columns of data besides row, column variables, 'variable', 'variableGroup' and 'isTotal' are considered.

statsLabInclude

Logical, if TRUE include the statistic label in the table.
By default only included if more than one statistic variables are available in the table.

rowVarLab

Named character vector with label for the rowVar variable(s).

rowVarTotalInSepRow

Character vector with rowVarTotalInclude (not in rowVarInSepCol) for which the total should be included in a separated row labelled 'Total'. Otherwise (by default) the total is included in the header row of each category.

vline

(flextable output) String mentioning how vertical lines should be included in the body of the table, either:

  • 'none' (default): no vertical lines included

  • 'auto': vertical lines included between sub-groups

hline

(flextable output) String mentioning how horizontal lines should be included in the body of the table, either:

  • 'none': no horizontal lines included

  • 'auto' (default): horizontal lines included between sub-groups

rowAutoMerge

(flextable output) Logical, if TRUE (by default) automatically merge rows, e.g. in case there is only one sub-category (e.g. categorical variable with only one group) or only one statistic per category.

rowVarFormat

(flextable output) Named list with special formatting for the rowVar. Currently, only possibility is to set the variable elements in bold, with: list(var1 = "bold"). (Use 'variable' for var or 'variableGroup' for group within categorical variables.)

rowTotalLab

(flextable output) string with label for the row with total.

labelVars

(optional) Named character vector with label for the row, column variable(s) or variable(s) to summarize.
Labels specified via dedicated parameter: e.g. rowVarLab, colVarLab, varLab have priority on this parameter.

Value

summaryTable reformatted in long format, with extra attributes:

If summaryTable is a list of summary tables, returns a list of corresponding summary tables in long format.

Author(s)

Laure Cougnaud


[Package inTextSummaryTable version 3.3.2 Index]