Hi there, and welcome to community.rstudio.com!
Without knowing how your function is structured and what your output looks 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.