# NOT RUN {
# Example: clear one of a or b in any row where both are set.
d <- data.frame(a = c(0, 0, 1, 1, 1, 1, 1, 1, 1, 1),
b = c(0, 1, 0, 1, 1, 1, 1, 1, 1, 1),
edited = FALSE)
program <- if_else_device( # detect rows with both a and b set
testexpr = qe((a+b)>1),
thenexprs = c(
if_else_device( # randomly clear one of a or b
testexpr = qe(runif(dplyr::n()) >= 0.5),
thenexprs = qae(a := 0),
elseexprs = qae(b := 0)),
qae(edited := TRUE)))
print(program)
plan <- partition_mutate_se(program)
print(plan)
res <- d %.>%
mutate_seb(., plan) %.>%
select_se(., grepdf('^ifebtest_.*', ., invert=TRUE))
print(res)
# }
Run the code above in your browser using DataLab