This typically converts the data from a wide to a long format. For each variable, a subset of interest based on a condition can be specified.
combineVariables(
data,
paramsList,
newVar,
labelVars = NULL,
fctTest = "==",
includeAll = FALSE,
labelAll = "Any"
)
Data.frame with records from data
extracted based on
the different conditions specified in paramsList
.
This data.frame contains an additional variable
(labelled based on newVar
) mentioning the
specific condition for which the record was extracted
(based label
, labelExtra
, labelVars
).
This variable is a factor whose levels are ordered based on the order
of the condition specified in paramsList
.
Data.frame with dataset to consider for the summary table.
nested list of parameters,
specifying how the records of interest should be selected.
There are two ways to select a subset of interest:
by specifying one unique variable of interest with:
var
: string with column of data
of interest
value
: value of var
of interest (only used if var
is specified).
If not specified only the values different than NA and '' are considered.
fctTest
: string with name or directly comparison function
to apply on var
to select subset of interest versus value
.
The function should take var
as first parameter and value
to compare to
as second parameter and returns a logical vector with TRUE or FALSE (of length var
)
if the condition is fullfilled.
If not specified, the records with var
equal to value
are retained
(fctTest
is set to '==').
label specification:
label
: string with label for the condition,
includde in the new 'variable' column.
If not specified and:
var
is specified: label is extracted from
labelVars
if available or set to var
otherwise.
var
is not specified: label should be specified.
labelExtra
: string with extra label, will be concatenated with label
by specifying a combination of variable of interest with:
exprs
: string with expression of columns of data
to select subset of interest
label
: string with complete label for the group
String with name of new variable to construct.
(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.
Default function to use to compare var
and value
specified
in each sublist of paramsList
.
This is only used if fctTest
is not specified in each sublist.
Logical, if TRUE (FALSE by default) include also the entire data as an additional subgroup.
String of group label for the entire data in case includeAll
is TRUE.
Laure Cougnaud