Create and render R Markdown documents
mainR Markdown documents (.Rmd) combine code, rendered output, and prose. They can be rendered to HTML, PDF, Word, or slideshows.
Using RStudio IDE
- Creation: Navigate to
File > New File > R Markdown. Follow the wizard to set a title, author, and output format (HTML is recommended). - Rendering: Click the Knit button in the IDE or use the keyboard shortcut
Cmd/Ctrl + Shift + Kto render the file and preview the output.
Manual Authoring
You can create a .Rmd file by writing Markdown prose and inserting code chunks:
- Insert Code Chunk: Use the keyboard shortcut
Ctrl + Alt + I(Windows/Linux) orCmd + Option + I(macOS). - Run Chunks: Click the run icon within the code chunk in RStudio to execute code interactively.
- Full Render: Use the "Knit to HTML" (or other format) command to execute all chunks and generate the final document.