View source: R/getSummaryStatisticsTable.R
getSummaryStatisticsTable | R Documentation |
Get summary statistics table
getSummaryStatisticsTable(
data,
var = NULL,
varFlag = NULL,
varLab = NULL,
varLabInclude = length(var) > 1,
varInclude0 = FALSE,
varIgnore = NULL,
varGeneralLab = "Variable",
varSubgroupLab = "Variable group",
varIncludeTotal = FALSE,
varTotalInclude = FALSE,
varTotalInSepRow = FALSE,
rowVar = NULL,
rowVarLab = NULL,
rowVarDataLevels = NULL,
rowOrder = "auto",
rowOrderTotalFilterFct = NULL,
rowOrderCatLast = NULL,
rowVarInSepCol = NULL,
rowVarFormat = NULL,
rowVarTotalInclude = NULL,
rowVarTotalByVar = NULL,
rowVarTotalInSepRow = NULL,
rowTotalLab = NULL,
rowInclude0 = FALSE,
rowAutoMerge = TRUE,
emptyValue = "-",
rowVarTotalPerc = NULL,
colVar = NULL,
colVarTotal = colVar,
colVarTotalPerc = colVarTotal,
colInclude0 = FALSE,
colVarDataLevels = NULL,
colTotalInclude = FALSE,
colTotalLab = "Total",
stats = NULL,
statsExtra = NULL,
statsVarBy = NULL,
statsPerc = c("statN", "statm"),
statsGeneralLab = "Statistic",
statsValueLab = "StatisticValue",
statsLabInclude = NULL,
subjectVar = "USUBJID",
filterFct = NULL,
dataTotal = NULL,
dataTotalPerc = dataTotal,
dataTotalRow = NULL,
dataTotalCol = NULL,
type = "auto",
byVar = NULL,
byVarLab = NULL,
checkVarDiffBySubj = "error",
labelVars = NULL,
outputType = "flextable",
statsLayout = ifelse("DT" %in% outputType, "col", "row"),
landscape = (style == "presentation"),
margin = 1,
rowPadBase = 14.4,
title = NULL,
footer = NULL,
file = NULL,
style = "report",
colorTable = getColorPaletteTable(style = style),
colHeaderTotalInclude = TRUE,
colHeaderMerge = TRUE,
fontsize = switch(style, report = 8, presentation = 10),
fontname = switch(style, report = "Times", presentation = "Tahoma"),
vline = "none",
hline = "auto",
pageDim = NULL,
columnsWidth = NULL,
expandVar = NULL,
noEscapeVar = NULL,
barVar = NULL,
...
)
data |
Data.frame with dataset to consider for the summary table. |
var |
Character vector with variable(s) of |
varFlag |
Character vector, subset of |
varLab |
Named character vector with label for each variable
specified in |
varLabInclude |
Logical, if TRUE
the name of the summary statistic variable(s) ( |
varInclude0 |
Logical, should rows with no counts
for the count
|
varIgnore |
Vector with elements to ignore in the |
varGeneralLab |
String with general label for variable specified in |
varSubgroupLab |
String with general label for sub-group of categorical variable(s) for count table, 'Variable group' by default. This will be included in the final table header (see 'rowVarLab' attribute of the output). |
varIncludeTotal |
This argument is deprecated, please use: 'varTotalInclude' instead. |
varTotalInclude |
Should the total across all categories of
|
varTotalInSepRow |
Logical, should the total per variable be included in a separated row (by default) or in the row containing the header of the variable? |
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. |
rowVarLab |
Named character vector with
label for the |
rowVarDataLevels |
Data.frame with unique combinations of |
rowOrder |
Specify how the rows should be ordered in the final table, either a:
To specify different ordering methods for different |
rowOrderTotalFilterFct |
Function used to filter the data used to order the rows
based on total counts (in case |
rowOrderCatLast |
String with category to be printed in the last
row of each |
rowVarInSepCol |
Character vector with |
rowVarFormat |
(flextable output) Named list with special formatting for the |
rowVarTotalInclude |
Character vector with |
rowVarTotalByVar |
Character vector with a row variable
used to categorize the row total. |
rowVarTotalInSepRow |
Character vector with |
rowTotalLab |
(flextable output) string with label for the row with total. |
rowInclude0 |
Logical, if TRUE (FALSE by default),
include rows with no records, based on all combinations
of the |
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. |
emptyValue |
String with placeholder used to fill the table for missing values, '-' by default. This value is typically used e.g. if not all statistics are computed for all specified row/col/var variables. |
rowVarTotalPerc |
Character vector with row variables by which the total
should be computed for the denominator for the percentage computation.
By default the total is only computed only by column (NULL by default).
If the total should be based on the total number of records per variable,
|
colVar |
Character vector with variable(s) to be included in columns.
If multiple variables are specified, the variables should
be sorted in hierarchical order,
and are included in multi-columns layout. |
colVarTotal |
String with column(s) considered to compute the total by,
reported in the header of the table, by default same as |
colVarTotalPerc |
String with column(s) considered to compute the total by,
used as denominator for the percentage computation, by default same as |
colInclude0 |
Logical, if TRUE (FALSE by default),
include columns with no records, based on all combinations
of the |
colVarDataLevels |
Data.frame with unique combinations of |
colTotalInclude |
Logical, if TRUE (FALSE by default) include the summary statistics across columns in a separated column. |
colTotalLab |
String, label for the total column 'Total' by default. |
stats |
(optional) Statistic(s) of interest to compute, either:
|
statsExtra |
(optional) Named list with functions for additional custom
statistics to be computed.
For example, to additionally compute the coefficient of variation, this can be set to:
|
statsVarBy |
String with variable in |
statsPerc |
String with 'base statistical variable' used to compute the percentage, either:
|
statsGeneralLab |
String with general label for statistics, 'Statistic' by default.
Only included if no |
statsValueLab |
String with label for the statistic value,
'StatisticValue' by default. |
statsLabInclude |
Logical, if TRUE include the statistic label
in the table. |
subjectVar |
String, variable of |
filterFct |
(optional) Function taking as input
the summary table with computed statistics and returning a subset
of the summary table.
|
dataTotal |
Data.frame used to extract the Total number of subject
per column in column header ('N = [X]').
It should contain the variables specified by |
dataTotalPerc |
Data.frame used to extract the total counts per column
for the computation of the percentage. |
dataTotalRow |
Data.frame used to extract the total count across all
elements of the row
variable, list of such data.frame for each |
dataTotalCol |
Data.frame from which the total across columns is
extracted (in case
If only a subset of the variables is specified in this list,
By default, |
type |
String with type of table:
|
byVar |
Variable(s) of |
byVarLab |
String with label for |
checkVarDiffBySubj |
String, 'error' (default), 'warning',
or 'none'.
Should an error, a warning, or nothing be produced
if a continuous variable ( |
labelVars |
(optional) Named character vector with label for
the row, column variable(s) or variable(s) to summarize. |
outputType |
String with output type:
|
statsLayout |
String with layout for the statistics names (in case more than one statistic is included), among:
|
landscape |
(flextable output) Logical, if TRUE the file is in landscape format. |
margin |
(flextable output) Margin in the document in inches
(1 by default).
This is used to specify the width of the table, from:
[ |
rowPadBase |
(flextable output) Base padding for row (in points), 14.4 by default (corresponds to 0.2 inches) |
title |
Character vector with title(s) for the table.
Set to NULL (by default) if no title should be included.
If multiple are specified, specified for each element of |
footer |
(flextable output) Character vector with footer(s) for the table. Set to NULL (by default) if no footer should be included. |
file |
(Optional) Name of the file the table should be exported to, either:
If NULL (by default), the summary table is not exported but only returned as output.
If |
style |
(flextable output) String with table style, either 'report' or 'presentation'. This parameter affects the fontsize, font family, color of the text and background, and table dimensions of the table. |
colorTable |
(flextable output) Named character vector with color for the table background/body/text/line,
e.g. created with the |
colHeaderTotalInclude |
Logical, if TRUE include the total of number of patients
( |
colHeaderMerge |
(flextable output) Logical, if TRUE (FALSE by default) the column header is merged. |
fontsize |
(flextable output) Integer with font size, by default:
8 if |
fontname |
(flextable output) String with font name, by default:
'Times' if |
vline |
(flextable output) String mentioning how vertical lines should be included in the body of the table, either:
|
hline |
(flextable output) String mentioning how horizontal lines should be included in the body of the table, either:
|
pageDim |
Numeric vector of length 2 with page width and height.
|
columnsWidth |
(expert mode) Column widths of the table. This is only used
for flextable and DT tables. |
expandVar |
(DT output) Character vector with variables of the summary table which should be expanded in the data. |
noEscapeVar |
(DT output) Character vector with variables of |
barVar |
(DT output) Character vector with variables of |
... |
(DT output) Extra parameters passed to the
|
Depending on the outputType
:
'data.frame-base': input summary table in a long format with all computed statistics
'data.frame': summary table in a wide format (
different columns for each colVar
), with specified labels
'flextable' (by default): flextable
object with summary table
'DT': datatable
object with summary table
If multiple outputType
are specified, a list of those objects, named
by outputType
.
If byVar
is specified, each object consists of a list of tables,
one for each element in byVar
.
Laure Cougnaud
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.