Should R studio reorder YAML material in multiformat documents?



I raised a question on stack overflow about how RStudio reorders the YAML document type arguments on generation. I’ve checked today and it’s still reproducible on Mac OS X 10_12_4 using Version 1.0.153

A reasonable answer was provided (though it’s somewhat beyond my ability to understand how technically correct it is).

I was wondering if the devs had an opinion on if this was by design, an uncontrollable side-effect or a feature, and if there were any other opinions from the community?


The reason it does this has mostly to do with the rmarkdown package, which relies on the ordering in the YAML in order to determine which output format to render by default.

When you click e.g. “Knit to PDF”, RStudio does two things:

  1. Makes PDF the default output format by moving it to the top
  2. Knits the document to the default output format

In most cases this is the behavior people want, because it enables quick iteration (now the next time you click Knit, you get a PDF.)

It would be possible for the IDE to decouple these things, and render to a format without making it the default. However, it’s not the majority case so isn’t currently implemented.


Thanks, clears it up nicely :slight_smile: