For this question and your other one please have a look at these two (related) articles:
- https://forum.posit.co/t/generating-markdown-report-in-shiny/1162
- https://forum.posit.co/t/generating-markdown-reports-from-shiny/8676
Maybe these could help you.