R gives error with the mean but not with median

Welcome to RStudio Community.

For us to diagnose your problem, we'll need a reproducible example. Please read this article for how to make one:

FAQ: What's a reproducible example (reprex) and how do I create one?

A quick way of doing this is to provide us the output of dput(reporttb) or, if its very long, dput(head(reporttb, 100)).