Hi, and welcome!
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.
A reprex
should be cut, paste and play with
- libraries
- representative data
- code, such as what you've shown
Peeps are much more likely to offer an answer if they don't have to reverse engineer the issue