R Markdown is fantastic for knitting to output formats where there is inline output. The code is written in the R Markdown file and the results appear inline in the output files.
But I'm wondering whether there could be a way to have the same chunk results appear inline in the raw R Markdown file, not just the output formats. We do have a solution for this within the RStudio IDE where, if you run chunks, the output will be displayed inline by default. But this is temporary; the only way of sharing them with the results is to knit the document or rely on collaborators running the code themselves in RStudio. Knitting the document to an output format is fine, of course, but sometimes for the sake of simplicity and ease it would often be better to work with just a single file.
An idea would be to have a special kind of output format, which didn't knit a new file, but would be recognised by RStudio and add outputs as plain text below the chunk when executed interactively. Plots would be saved behind the scenes and code to display them then added below the line. If the document was also rendered into another format, that would need to be detected and the inline outputs removed when knitting (to avoid the outputs appearing twice in the output file).
My inspiration for this idea comes from Org Mode in Emacs, which implements something similar. Org Mode can also knit to other output formats, but still gives you the option of using just a single file, but one with inline outputs.
I'm curious as to whether people think this would be a good idea? And whether there are drawbacks which I'm not considering? I don't think this would be a use case for complicated documents nor do I think it should be the default. It does seem a little at odds with the usual R Markdown way of doing things. But it also seems like a good solution for many simple use cases.