Week 1 Lab


This week’s lab is aimed at familiarizing you with R and RStudio. R is a “free software environment for statistical computing and graphics.” While R was built primarily for statistical work, it serves many functions that extend well beyond statistics. R works as both a scripting environment (where programs are written and then run) and a command line interface (where commands are entered and return values immediately). R and its packages are freely available and are supported by a large user base.

Before we can get to working with data and , it is important to understand some fundamental concepts in computing and how they work in R, specifically. In this section you will learn how to:

  • navigate the RStudio interface

  • use basic commands in R

  • differentiate between object types in R

  • visualize data in R

A note on completing these exercises

These exercises use different conventions to represent the code to be typed into the command line and the results you get back. The code you are meant to enter is presented in blue monospaced font. For example:


If you are meant to provide a value for a part of the code, that section will be italicized:


Results from R that are returned at the command line are indicated in bolded, purple monospaced font:

[1] 17 4 8 9 13 12 9 6 6 11

[1] "Ben"

It is possible to copy and paste code from this document directly into the command line, but for now I recommend that you enter to code yourself to get a sense of how command line operations work.