Jonathan Baron <baron <at> psych.upenn.edu> writes: : ces$score <- ifelse(ces$question %in% c(1,3,5),5-ces$score,ces$score) One minor improvement in readability might be: ces$score <- with(ces, ifelse(question %in% c(1,3,5), 5-score, score))