2.2 Intro R Markdown

2.2.1 General

This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.

plot(cars)

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.

2.2.2 Knitting to other formats

You can knit notebook into PDF or Word. Make sure to install the tinytex package using the following code: install.packages("tinytex"). If you already use  with another distribution, then you do not need to install tinytex (though this works perfectly out of the bag). Then from the menu above (Knit), then choose Knit to PDF or Knit to Word. This is an excellent way to get your work fully written within RStudio: You will write a text (like this), have a specific structure and also have all your results in one place. This allows for transparency and replicability.