detStructAddVarLabels {behaviorchange} | R Documentation |
Functions to preprocess determinant structures
Description
These functions are used in conjunction with the
determinantStructure
family of funtions to conveniently work
with determinant structures.
Usage
detStructAddVarLabels(
determinantStructure,
varLabelDf,
varNameCol = "varNames.cln",
leftAnchorCol = "leftAnchors",
rightAnchorCol = "rightAnchors",
subQuestionCol = "subQuestions",
questionTextCol = "questionText"
)
detStructAddVarNames(determinantStructure, names)
detStructComputeProducts(determinantStructure, data, append = TRUE)
detStructComputeScales(
determinantStructure,
data,
append = TRUE,
separator = "_"
)
Arguments
determinantStructure |
The |
varLabelDf |
The variable label dataframe as generated by the
|
varNameCol |
The name of the column of the |
leftAnchorCol |
The name of the column of the |
rightAnchorCol |
The name of the column of the |
subQuestionCol |
The name of the column of the |
questionTextCol |
The name of the column of the |
names |
A character vector with the variable names. These are matched
against the regular expressions as specified in the
|
data |
The dataframe containing the data; the variables names specified
in |
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
### Create some bogus determinant data
detStudy <- mtcars[, c(1, 3:7)];
names(detStudy) <- c('rUse_behav',
'rUse_intention',
'rUse_attitude1',
'rUse_attitude2',
'rUse_expAtt1',
'rUse_expAtt2');
### Specify the determinant structure
### First a subdeterminant
expAtt <-
behaviorchange::subdeterminants("Subdeterminants",
"expAtt");
### Then two determinants
attitude <-
behaviorchange::determinantVar("Determinant",
"attitude",
expAtt);
intention <-
behaviorchange::determinantVar("ProximalDeterminant",
"intention",
attitude);
### Then the entire determinant strcture
detStruct <-
behaviorchange::determinantStructure('Behavior',
list('behav',
behaviorRegEx = 'rUse'),
intention);
### Add the variable names
behaviorchange::detStructAddVarNames(detStruct,
names(detStudy));
### Add the determinant scale variable to the dataframe
detStudyPlus <-
behaviorchange::detStructComputeScales(detStruct,
data=detStudy);
### Show its presence
names(detStudyPlus);
mean(detStudyPlus$rUse_Determinant);