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.
Here, although the code is complete, representative data is missing that would produce the same error message. It's hard to eyeball the code and guess which line is throwing the error, and, understandably, few are willing to expend the effort to reverse engineer the problem.
Can you construct a reprex
to better help us to help you?