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. Posting code with all required library statements, and especially representative data objects, to allow cut-and-paste removes a lot of friction from having to reverse engineer the problem, even when it's relatively straightforward such as this.