Start coding

Console, script,or Notebook

After installing R, RStudio, and the Tidyverse packages, you’re ready to send commands to the R-interpreter.

Reproducibility starts at the foundation! Always begin by opening a project. See New Projects for tips.

We recommend entering your code in code-chunks (Insert > code-chunks) within coding notebooks.


R console quadrant in RStudio

A very simple way to code is to send commands directly to the console (bottom-left quadrant in RStudio). For example: in the RStudio console, type cars — then hit the enter key.

This approach is convenient but not very reproducible.

Notebooks - RECOMENDED

We recommend using Quarto Documents. This provides a visual notebook where coders blend code with prose, then render publishable documents from the quarto-document. Another option is R Markdown documents; R Markdown is the predecessor to Quarto.

Sample Quarto Document

Sample Quarto Document

The basic steps are

  1. Begin new Quarto document (File > New file > Quarto document)
  2. Compose explanation of goals and code-chunks using natural language (i.e. prose)
  3. Add code-chunks (Ctrl-Alt-i) to compose code. (intersperse code-chunks with prose)
  4. Render document into a publishable report1

Scripts - plain vanilla

You can also code the old fashion way using a plain vanilla .R script.2


  1. Many report formats are available including: PDF, MS Word, Slides, PPTX, HTML, EPUB, Web sites, Blogs, Interactive interfaces.↩︎

  2. File > New file > R script. There is no mandate to join the twenty-first century and honor academic values like reproducibility, such as rendering reports from code. You do you. I don’t judge 😃↩︎