Appendix A — Bonus lesson - Markdown Files
There are two ways to write and save R code: scripts (.R) and markdown files (.Rmd or .qmd).
Scripts are very bare bones. You cannot add “normal” text or formatting to them and their output is not saved anywhere in the file. This is the ideal format for purely utilitarian code. They are equivalent to writing a document in Notepad.
Markdown files are formatted files that allow you to present code in a reader-friendly design. Unlike scripts, you can add “normal” text and formatting, and the code output can be saved and displayed directly in the file. You can even add code from multiple different languages! This is the ideal format when visually examining your output matters. They are equivalent to writing a document in Word.
Why are they called “Markdown files”? Markdown is simply a language for creating formatted text (like html). For practical use, all that matters is markdown files preserve formatting (and therefore allow text, images, etc. to be in the file) while scripts do not.
Newer versions of R have three versions of markdown files: R markdown, R notebook, and Quarto document.
R markdown and R notebook files are functionally the same from a coding perspective (hence why they have the same extension, .Rmd). The only practical difference is you can preview R notebooks without knitting them; this can be useful if you want to quickly view the output.
Quarto documents (.qmd) differ from R markdown in that they’re more general; unlike R markdown, which was primarily built with the R language in mind, Quarto is language agnostic. However, aside from some syntax differences, it’s practically the same as a .Rmd file.
You can use either format for your code. Quarto is newer and has less documentation currently, but it will likely have more support in the long run, and is preferable for some complex use cases.