Hi there, and welcome to community.rstudio.com!
Without knowing what your code and data look like, it's a little difficult to give good guidance. To help you get the right help for your question, can you please turn it into a reprex (reproducible example)? This will ensure we're all looking at the same data and code. A guide for creating a reprex can be found here.