Can you please convert back to the original form - `ifelse()` isn't appropriate here as it's vectorised.