A First Look at RStudio

Modern Plain Text Computing
Week 01

Kieran Healy

August 2025

Getting to know R and RStudio

We want to do our work reproducibly

The RStudio IDE

An IDE for R

An IDE for Meals

RStudio at startup

RStudio schematic overview

RStudio schematic overview

RStudio at startup

RStudio at startup

RStudio at startup

RStudio at startup

RStudio at startup

Your code is what’s real in your project

Consider not showing output inline

Writing documents

Use Quarto to produce and reproduce your work

Where we want to end up

Where we want to end up

PDF out

Where we want to end up

HTML out

Where we want to end up

Word out

How to get there?

  • We could write an R script with some notes inside, using it to create some figures and tables, paste them into our document.
  • This will work well. The more complex our projects get the more likely it is we will write code like this. It will also look less and less like a single all-in-one-breath script and more like a structured collection R files that combine to do many things.
  • But to begin we can also do things a little differently, by taking a more notebook-based approach. For many simpler and routine uses, this will be better.

We can make this …

… by writing this

The code gets replaced by its output

This way of doing things is called a Literate Programming or Notebook approach.

Quarto document

Quarto document annotated

  • This approach has its limitations, but it’s very useful and has many benefits.

Strengths and weaknesses

Notebooks work smoothly when

  • Your document or report is small and self-contained.
  • Your analysis is quick or lightweight.
  • You are making slides.
  • You are making a lot of similar reports from a template.
  • You regularly refer to calculated items in the text of your analysis.

Notebooks can get awkward when

  • Your analysis has many pieces.
  • Your project has many authors.
  • Your analysis needs a lot of scaffolding in code.
  • You have a lot of different outputs.

In Practice

Notebook-style documents like Quarto files are great as part of larger projects. The more complex your project, the less likely it will straightforwardly fit into a single notebook. More likely you will find yourself, first, splitting parts of a complex project up into different notebooks; and then, second, writing R scripts that programatically clean and pre-process data, run analyses, and produce some outputs—such as key tables and figures—that you then incorporate into a Quarto document indirectly. Not by copying and pasting, but by pointing to those outputs.

Basic markdown summary

Desired style Use the following Markdown annotation
Heading 1 # Heading 1
Heading 2 ## Heading 2
Heading 3 ### Heading 3 (Actual heading styles will vary.)
Paragraph Just start typing
Bold **Bold**
Italic *Italic*
Images [Alternate text for image](path/image.jpg)
Hyperlinks [Link text](https://www.visualizingsociety.com/)
Unordered Lists
- First - First
- Second. - Second
- Third - Third
Ordered Lists
1. First 1. First
2. Second. 2. Second
3. Third 3. Third
Footnote.¹ Footnote[^notelabel]
¹The note’s content. [^notelabel] The note's content.

The right frame of mind

  • This is like learning how to drive a car, or how to cook in a kitchen … or learning to speak a language.
  • After some orientation to what’s where, you will learn best by doing.
  • Software is a pain, but you won’t crash the car or burn your house down.

Create a new Quarto Project

  • File > New Project > New Directory > Quarto Project
  • Choose a location for a folder named mptc
  • Initialize a git repository
  • Check the “Open in new session” box
  • Click “Create Project”

Create a new Quarto Document

  • Once the project opens, create a new file (File > New File > Quarto Document)
  • Choose “Document” and “HTML” as the output format
  • Save the file as scratch.qmd in the mptc folder

For now

  • Get used to editing text files in RStudio and rendering them to HTML or PDF.
  • Don’t worry about writing any code at this point. Treat it as a way to take notes for the class.
  • In the same way that you should be reading around and beyond the assigned readings for other classes, you should also be exploring R and RStudio on your own. Try to do things; see what happens.