Skip to content

Commit

Permalink
Update question routing for new survey
Browse files Browse the repository at this point in the history
  • Loading branch information
ldavies99 committed Oct 18, 2023
1 parent af6fc5a commit dbd6af2
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions R/question-routing.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,50 @@

apply_skip_logic <- function(data) {

conditions <- list(data$workplace %in% c("Civil service, including devolved administations", "test"),
conditions <- list(data$workplace != "NHS or local healthcare service",
data$workplace %in%
c("Civil service, including devolved administations",
"NHS or local healthcare service",
"test"),
data$department != "Office for National Statistics",
data$department %in% c("Office for National Statistics", "test"),
!is.na(data$ONS_directorate),
data$pay_band != "Local Authority or NJC",
data$pay_band != "Other / Not sure",
!is.na(data$NHS_band),
data$primary_work_country != "Scotland",
data$primary_work_country != "Wales",
data$primary_work_country != "Notherin Ireland",
!is.na(data$England_NHS_organisation),
!is.na(data$Scotland_NHS_organisation),
!is.na(data$Wales_NHS_organisation),
data$highest_qualification != "Any other qualification",
data$code_freq != "Never",
data$other_coding_experience != "No",
data$prev_coding_experience != "No",
data$heard_of_RAP != "No")
data$heard_of_RAP != "No",
data$have_RAP_champ %in% c("Yes", "test"),
)

skipped_cols <- list(colnames(data)[which(colnames(data) == "CS_grade"):which(colnames(data) == "ONS_directorate")],
colnames(data)[which(colnames(data) == "ONS_directorate")],
colnames(data)[which(colnames(data) == "CS_grade"):which(colnames(data) == "Northern_Ireland_NHS_organisation")],
colnames(data)[which(colnames(data) == "prof_DE"):which(colnames(data) == "prof_CS_other")],
colnames(data)[which(colnames(data) == "prof_DE"):which(colnames(data) == "Northern_Ireland_NHS_organisation")],
colnames(data)[which(colnames(data) == "pay_band"):which(colnames(data) == "Northern_Ireland_NHS_organisation")],
colnames(data)[which(colnames(data) == "NHS_band")],
colnames(data)[which(colnames(data) == "NHS_band"):which(colnames(data) == "NJC_grade")],
colnames(data)[which(colnames(data) == "NJC_grade")],
colnames(data)[which(colnames(data) == "England_NHS_organisation")],
colnames(data)[which(colnames(data) == "England_NHS_organisation"):which(colnames(data) == "Scotland_NHS_organisation")],
colnames(data)[which(colnames(data) == "England_NHS_organisation"):which(colnames(data) == "Wales_NHS_organisation")],
colnames(data)[which(colnames(data) == "Scotland_NHS_organisation"):which(colnames(data) == "Northern_Ireland_NHS_organisation")],
colnames(data)[which(colnames(data) == "Wales_NHS_organisation"):which(colnames(data) == "Northern_Ireland_NHS_organisation")],
colnames(data)[which(colnames(data) == "Northern_Ireland_NHS_organisation")],
colnames(data)[which(colnames(data) == "qual_1_subject"):which(colnames(data) == "qual_3_learn_code")],
colnames(data)[which(colnames(data) == "prac_use_open_source"):which(colnames(data) == "misc_coding")],
colnames(data)[which(colnames(data) == "coding_ability_change"):which(colnames(data) == "first_learned")],
colnames(data)[which(colnames(data) == "line_manage"):which(colnames(data) == "reproducible_workflow")],
colnames(data)[which(colnames(data) == "first_learned")],
colnames(data)[which(colnames(data) == "know_RAP_champ"):which(colnames(data) == "RAP_comments")])
colnames(data)[which(colnames(data) == "have_RAP_champ"):which(colnames(data) == "RAP_comments")],
colnames(data)[which(colnames(data) == "know_RAP_champ")],
)

for(i in 1:length(conditions)){
data <- enforce_skip_logic(data, conditions[[i]], skipped_cols[[i]])
Expand Down

0 comments on commit dbd6af2

Please sign in to comment.