How to optionally comment out part of an RMarkdown file

That is possible - check out this thread with the included links, it does seem similar to the problem you are facing: Create RMarkdown headers and code chunks in purrr - #4 by Equation. Let us know how it goes after you've tried.