my_q_block <- data.frame(
resp_id = 1:5, # Unique to respondent
q10_1 = c(1, 1, 0, 0, 0),
q10_2 = c(0, 1, 0, 0, 0),
q10_3 = c(0, 0, 1, 0, 0),
q10_98 = c(1, 0, 0, 1, 0), # None of the above
q10_99 = c(0, 0, 0, 0, 1) # Item not answered
)
# Make sure that if "None of the above" and "Item skipped" are selected
# none of the other question options are selected:
try(
expect_exclusive(
c(q10_98, q10_99),
starts_with("q10_"),
data = my_q_block
)
)
Run the code above in your browser using DataLab