In the presence of missing values, boxcox_trans does not work:
trans <- scales::boxcox_trans(p = 0)
# This works:
trans$trans(1:3)
# This does not work:
trans$trans(c(1:3, NA_real_))
The issue is with the if clause. Because any(c(1:3, NA_real_) > 0) returns NA, the condition cannot be evaluated. Adding na.rm = TRUE should fix it. I'm happy to modify the R and the test file if that is helpful.