Lab 0: Getting Started
R, RStudio, and reproducible reports
Download the student lab template
Goals
By the end of this lab, you should be able to:
- identify the main parts of RStudio;
- run R code and save a result as an object;
- open, edit, save, and render a Quarto (
.qmd) file; - recognize where code, output, and written interpretation belong; and
- identify areas in which you may want additional support.
No previous R experience is expected.
The course workflow
We will use three connected tools:
- R performs the calculations.
- RStudio Desktop gives us an organized place to write code, inspect data, and view results.
- Quarto combines prose, code, tables, and figures into a reproducible report.
Open RStudio. Its four panes usually contain the source editor, console, environment/history, and files/plots/help. The precise arrangement is less important than knowing where you write a report and where R displays results.
Exercises
Exercise 1. R as a calculator
Enter the following in the Console and press Return:
2 + 2
10 / 4
sqrt(81)R prints a result but does not save it. To save a result, assign it a name:
Exercise 2. Create an object
policy_budget <- 1250000
program_share <- 0.18
program_budget <- policy_budget * program_share
program_budgetThe assignment arrow, <-, means “store the value on the right under the name on the left.”
Note that only the information inside a code chunk can be executed as R code
Exercise 3. A short, ungraded diagnostic
This is only a starting-point check. It will help us calibrate examples and support.
What experience, if any, do you have with spreadsheets, statistics, or coding?
What would you most like to learn in this course?
Try it
At this point let’sRender our Quarto document
On Your Own
Create an object called weekly_hours, use it to estimate the total scheduled class hours in a 15-week semester, and explain what your result means.
Bonus
Add a new chunk under the On Your own section and create an object called students containing the number of students in your section. Then calculate the number of four-person groups that could be formed.