look over my r square formula in r for my random forest model

Job ID: 32730618

Budget: $10 – $30 USD

I am working on a random forest model on R. I have completed the model and when I plot, the frequency of the r-square values has a negative range to positive two range. I am not sure if I am doing something wrong with my r-square formula.

the script was attached. line 195-197 is my r-square formula