Diving into R programming and Quarto

ENS-215

January 8, 2026

Lecture Topics

  • Checking-in
    • R and RStudio installed?
    • Signed up for DataCamp and Posit Cloud?
    • Access to website, Nexus,…?
  • R and RStudio
  • Test driving R

R and RStudio

  • R is the programming language that does all of the computations. It is the “brains” behind the operation that interprets all of the commands we send to it.
  • RStudio is the Integrated Development Environment (IDE) which provides a convenient interfaces for working in R.

Let’s open up RStudio and explore.

Windows in RStudio

When you open RStudio you see a number of windows (panes). Some of the key ones are

  • Editor
  • Environment
  • Console
  • Viewer
  • Packages
  • Help
  • Plots

Let’s walk through each of these windows.

Packages in R

Packages are a collection of functions that allow you to easily perform useful operations. You can think of packages as “apps” (like you might install on a phone/computer) that add functionality to your phone/computer.

You can install packages directly in R by typing install.packages("package_name_here") directly in the console or by using the install button in your “Package” pane.

Once you’ve installed a package you never need to install it again, but each time you open R and want to use it you need to load the package using library("package_name_here").

If you have R and RStudio on your computer, let’s go ahead and install the tidyverse package (if you haven’t yet done so)

Programming (Coding) in R

  • Type directly into the console (fine for quick tests/checks or using R as a calculator)
  • Write your code as an R script (text file that contains your code and can be run directly in R)
  • Write your code in a Quarto notebook (allows you to combine your code, results/output, and nicely formatted text)

Quick note on the Console

  • This is where your code is sent to be run
  • The > is called the prompt. It indicates that R is ready to receive commands
  • If you don’t see an > then you may have typed an incomplete command. You can restart by pressing ESC or you can complete the command and hit Enter
  • If you want to clear the text in the Console window hit Ctrl + L

Quick notes on programming

  • Computers do what you tell them to do
  • You are smart and will tell the computer what to do
  • However all your commands need to be perfect, otherwise the computer won’t know what to do
  • This means your code needs to be typed correctly

Some reassuring reminders/advice

  • Learning programming/data science is an iterative process. Don’t worry if everything doesn’t “click” the first time you see it. As the term progresses, take the time to look back at previous readings, exercises, material and you will learn things that you may have missed the first time around.
  • Practice is vital. Like learning a language, you can’t do it passively. Try new things, test out ideas, copy/paste/tweak code that you want to learn to use.
  • You will see most of the concepts many times throughout the term, each time you will learn a new layer/aspect.
  • Once you become comfortable with the basics learning new things becomes much, much easier.
  • Don’t focus on memorizing how to do everything, just try to get a feel for what you are doing. The key thing is to become familiar with how to do something and then you can easily look back at your old code/notes or Google it if you forget later on.

Preparing your directories and work environment

Before we get started let’s discuss two important topics that are key to maintaining an organized and streamlined work environment.

  • Directories
    • Create a directory for this class. I recommend you call it ENS_215.
    • Create a sub-directory for your lecture material. I recommend you call it Lectures
  • Projects
    • Create a project in your Lectures folder

Now let’s dive right into some programming

  1. Open up your Lectures project and create a new Quarto notebook
  2. Follow along with the html Quarto notebook on our class site and create your own Quarto notebook We’ll go over some quick basics before you try to work through the notebook.