It's hard to say without looking at your exact code.
Can you please turn this into a REPRoducible EXample of your problem?
In case you don't know how to make a reprex, here's a great link: