It would be much easier to help you if your example was reproducible. The fact that we don't have your data (or a piece of it) makes it hard to debug your code on your end. If you want to know more about asking a reproducible question, please check this: