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.
Console
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.
The basic steps are
- Begin new Quarto document (
File > New file > Quarto document
) - Compose explanation of goals and code-chunks using natural language (i.e. prose)
- Add code-chunks (
Ctrl-Alt-i
) to compose code. (intersperse code-chunks with prose) - Render document into a publishable report1
Recommended Quarto links
Quarto tutorial (Includes step-by-step hello.qmd document: from authoring to rendering )
Quarto FAQ for R Markdown users
Quarto example publication types. Plus guides and deep-references docs
Scripts - plain vanilla
You can also code the old fashion way using a plain vanilla .R script.2
Footnotes
Many report formats are available including: PDF, MS Word, Slides, PPTX, HTML, EPUB, Web sites, Blogs, Interactive interfaces.↩︎
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 😃↩︎