This is the error message that keeps popping up;
processing file: Template4WorkReport--5-.Rmd
Quitting from lines 56-81 [unnamed-chunk-1] (Template4WorkReport--5-.Rmd)
Error:
! object 'r' not found
Execution halted
There the codes are all correct because I get results.
The error you're getting is suggesting that somewhere in your code you are calling an object "r" that you have not yet made. Do you see anywhere in the code that that may be the case? It is possible you have defined "r" after the code that is asking for it.
Start by doing rm(list = ls()) to clear your environment and run all the code again from scratch and let me know the results,