Sounds challenging. I'm not sure that I can help, but there may be people in the community that can, even though they don't have a magic snippet in their utils
folder. But that's unlikely without a reprex
, since few will try to reverse-engineer a problem.
Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers.