This may not answer your question and apologies if I miss the plot completely here but using tidyverse functions should be preferable due to parsimony. Note how I also separate the functions onto their own lines that eases error tracking if needed.
Code:
library(tidyverse)
data %>%
mutate(pre_resp =
1 - sum(
across(3:16)),
post_resp =
1 - sum(
across(17:30)),
.by = participant) %>%
select(participant, pre_resp, post_resp)
Result
# A tibble: 6 × 3
participant pre_resp post_resp
<int> <dbl> <dbl>
1 39496 -3.33 -0.333
2 40008 -2.33 1.33
3 39550 1 -1.67
4 39530 -7.67 0.667
5 39956 -2.33 2
6 39941 1.67 1.33
Since you did ask for any advice, I hope you will take something from the above.
PS remember to up- or downvote any answers or comments.