This is an old version of the class, kept for posterity. If you're seeing this, you probably want to check the URL and go to the latest version.

R Lab 1 - Setting up your environment

Due Monday, February 3, 2025

This lab has three goals:

  1. Get your R environment is set up correctly
  2. Introduce you to the idea of Quarto files
  3. Create your first network graph

We will be using VSCode as our development environment. This is a popular, open source Integrated Development Environment. This is the software that you will actual open and use to do all of your work.

Under the hood, VSCode will use Quarto and R. Quarto is a tool that lets you write code and text in the same document, and then convert it to a variety of formats, including PDF, HTML, and Word. R is even lower level, and is the engine that actually runs the code that you write.

For the first step, you will need to download and install the three main piece of software that we will be using: Quarto, VSCode, and R.

Install Quarto

Install VSCode

Install R

  • Install R. This is a really old, janky-looking site, but I promise it’s real.

Try to run the lab

  1. Create a folder on your computer called COM_411_Labs
  2. Right-click on this link to Lab 1 and save it into the COM_411_Labs folder
  3. Open VSCode
  4. Click on the Extensions icon on the left (it’s 3 attached squares and one floating square)
  5. Search for “quarto” and install the quarto extension
  6. Search for “R” and install the R extension
  7. In VSCode, Click File > Open Folder; Navigate to the COM_411_Labs folder that you created earlier and open it. You should see the lab_1
  8. Click on the lab_1_quarto.qmd file, and it should open in the main window of VSCode. At this point, it may ask if you want to install “languageserver”. You can click “Install” if it asks.
  9. Scroll down to line 36. You should see a little button that says “Run Cell”. Push that button, and a terminal will open at the bottom of the screen. This will run the R code in the cell.
  10. In the R shell at the bottom of VSCode, paste the following:
    • install.packages(c("rmarkdown","tidyverse","ggraph","tidygraph","igraphdata"))
    • It will ask you what CRAN mirror you’d like to use. You can choose something in the US.
    • If it asks if you want to install from source, you can type “no”
    • This will show a bunch of crazy messages for a while. You can probably ignore them.
    • WINDOWS USERS: There’s a chance that this won’t work because VSCode doesn’t know where R is. This page has some instructions on how to fix it. Look under “Connect R”. If you can’t get it to work, ask a neighbor (or me) for help.
  11. Install tinytex. Click the Quarto Preview terminal (in the bottom right) and type:
    • quarto install tinytex
  12. Click the “Preview” icon at the top right, and hopefully it works!
  13. Read the document, do the exercises at the bottom, and then preview the document again. Notice that there is a new PDF file in the folder.
  14. Upload the PDF to Brightspace! You did it!!

If things aren’t working then ask a neighbor for help.

Video Walkthrough

This was from an older version of VSCode, but should still be helpful:

Set up Github Copilot

If you want to use Github Copilot

  1. Sign up for an account at Github education
  2. Install the GitHub Copilot extension in VSCode
  3. Authenticate using the popup that shows up in the bottom right

We will talk more about how to use Copilot in class.