I think you need to work on you reproductible example so that it is easier to understand your issue.
Right now, it is not obvious to me what you are doing, what is going wrong and what you expect.
Rmarkdown is a text file that you can save. With shiny runtime you can execute some shiny element inside this document. This happens in a shiny session in a browser window but what going on in this window can't be saved in the rmarkdown file.
You could find parametrized rmarkdown or shiny application whith shiny bookmarking useful maybe. It is a guess based a small information I have right now.