'x must be numeric' when plotting histogram

the histogram snippet you shared relies on my_data$my_variable
after that you wrote a lot of code, none of which even mentions my_data$my_variable.

I think there are some issues with your code. there are a lot of statements that calculate, but then don't store their results in any other variable to be referenceable again later. i.e. the various mean() calculations you perform. They dont seem to go anywhere...

Could you produce a proper reprex ?