I don't really follow this question. There seems to be a pretty big disconnect between the issues you write about and the rmarkdown code provided.
I would really encourage you to review the following guide, FAQ: Tips for writing R-related questions.
For example, the guide emphasizes asking coding questions with a reprex
. You may have noticed that many people here request issues come in the form of a minimal reprex
, that's because asking questions this way saves answerers a lot of time helping you get your issue resolved.