### Get example data
dat <- get(data("BBC_pp15.1", package="behaviorchange"));
### Individual-level version, for one sub-determinant
P_delta_example <-
behaviorchange::potential_for_change_index(
data=dat,
determinants='highDose_attitude',
target='highDose_intention'
);
head(P_delta_example);
hist(P_delta_example);
### Sample-level version
behaviorchange::potential_for_change_index(
data=dat,
determinants='highDose_attitude',
target='highDose_intention',
sampleLevel = TRUE
);
### Individual-level for multiple determinants
P_delta_example <-
behaviorchange::potential_for_change_index(
data=dat,
determinants=c('highDose_attitude', 'highDose_perceivedNorm'),
target='highDose_intention'
);
head(P_delta_example);
### Sample-level version for multiple determinants
behaviorchange::potential_for_change_index(
data=dat,
determinants=c('highDose_attitude', 'highDose_perceivedNorm'),
target='highDose_intention',
sampleLevel = TRUE
);
### Get the Potential for Change Index Type 2
behaviorchange::potential_for_change_index(
data=dat,
determinants=c('highDose_attitude', 'highDose_perceivedNorm'),
target='highDose_intention',
type = '2',
sampleLevel = TRUE
);
### Get a Determinant Selection Table
behaviorchange::determinant_selection_table(
data=dat,
determinants = c('highDose_AttBeliefs_long',
'highDose_AttBeliefs_intensity',
'highDose_AttBeliefs_euphoria'),
target = 'highDose_intention',
sortBy = 6
);
### R Markdown partials can smoothly be included in RMarkdown documents
behaviorchange::determinantSelectionTable_partial(
behaviorchange::determinant_selection_table(
data=dat,
determinants = c('highDose_AttBeliefs_long',
'highDose_AttBeliefs_intensity',
'highDose_AttBeliefs_euphoria'),
target = 'highDose_intention',
sortBy = 6
)
);
### Room for improvement for one variable
head(
room_for_improvement(
dat$highDose_AttBeliefs_long
)
);
room_for_improvement(
dat$highDose_AttBeliefs_long,
sampleLevel = TRUE
);
### For multiple (sub-)determinants
head(
room_for_improvement(
dat[, c('highDose_AttBeliefs_long',
'highDose_AttBeliefs_intensity',
'highDose_AttBeliefs_euphoria')]
)
);
room_for_improvement(
dat[, c('highDose_AttBeliefs_long',
'highDose_AttBeliefs_intensity',
'highDose_AttBeliefs_euphoria')],
sampleLevel = TRUE
);
Run the code above in your browser using DataLab