determinantStructure Preprocessing
Functions to preprocess determinant structures
These functions are used in conjunction with the determinantStructure
family of funtions to conveniently work with determinant structures.
- Keywords
- utilities
Usage
detStructAddVarLabels(determinantStructure,
varLabelDf,
varNameCol = "varNames.cln",
leftAnchorCol = "leftAnchors",
rightAnchorCol = "rightAnchors",
subQuestionCol = "subQuestions",
questionTextCol = "questionText")detStructAddVarNames(determinantStructure, names)
detStructComputeProducts(determinantStructure, dat, append = TRUE)
detStructComputeScales(determinantStructure, dat, append = TRUE, separator = "_")
Arguments
- determinantStructure
The
determinantStructure
object.- varLabelDf
The variable label dataframe as generated by
processLSvarLabels
. It is also possible to specify 'homemade' dataframe, in which case the column names have to specified (see the next arguments).- varNameCol
The name of the column of the
varLabelDf
that contains the variable name. Only needs to be changed from the default value ifvarLabelDf
is not a dataframe as produced byprocessLSvarLabels
.- leftAnchorCol
The name of the column of the
varLabelDf
that contains the left anchor. Only needs to be changed from the default value ifvarLabelDf
is not a dataframe as produced byprocessLSvarLabels
.- rightAnchorCol
The name of the column of the
varLabelDf
that contains the right anchor. Only needs to be changed from the default value ifvarLabelDf
is not a dataframe as produced byprocessLSvarLabels
.- subQuestionCol
The name of the column of the
varLabelDf
that contains the subquestion. Only needs to be changed from the default value ifvarLabelDf
is not a dataframe as produced byprocessLSvarLabels
.- questionTextCol
The name of the column of the
varLabelDf
that contains the question text. Only needs to be changed from the default value ifvarLabelDf
is not a dataframe as produced byprocessLSvarLabels
.- names
A character vector with the variable names. These are matched against the regular expressions as specified in the
determinantStructure
object, and any matches will be stored in thedeterminantStructure
object.- dat
The dataframe containing the data; the variables names specified in
names
(when callingdetStructAddVarNames
) must be present in this dataframe.- append
Whether to only return the products or scales, or whether to append these to the dataframe and return the entire dataframe.
- separator
The separator to use when constructing the scale variables names.
Details
This family of functions will be explained more in detail in a forthcoming paper.
Value
detStructAddVarLabels
and detStructAddVarNames
just change the
determinantStructure
object; detStructComputeProducts
and detStructComputeScales
return either the dataframe with the
new variables appended (if append
= TRUE
) or just a
dataframe with the new variables (if append
= FALSE
).
References
(Forthcoming)
See Also
determinantStructure
, determinantVar
,
subdeterminants
, subdeterminantProducts
,
detStructCIBER
Examples
# NOT RUN {
### Generate a silly determinant structure
detStruct <- determinantStructure('This makes no sense',
list('mpg',
behaviorRegEx = 'mpg'),
determinantVar("Proximal determinant",
"t",
determinantVar("Determinant",
"p",
subdeterminants("Subdeterminants",
"a"))));
### Add the variable names
detStructAddVarNames(detStruct, names(mtcars));
### Add the determinant scale variable to the dataframe
mtcarsPlus <- detStructComputeScales(detStruct, mtcars);
### Show its presence
names(mtcarsPlus);
mean(mtcarsPlus$mpg_Determinant);
# }