### 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);
Run the code above in your browser using DataLab