Pre-work

We’ll be going over Functions, Lists, and Loops in this session. Some familiarity with using R and opening RStudio is helpful if you are actively participating, otherwise all are welcome to watch and learn.

R and the RStudio IDE are required. See the first module on R Basics for guidance.

Session Files on Local Drive

  1. Clone the repo https://github.com/psrc/intro-code-org onto your local drive.

  2. Download the CHAS zip file of the 2015-2019 ACS 5-year average data for Census counties from here.

Make sure that the repo and other files for the session are on your local drive. If they are on PSRC’s network, you may experience extreme sluggishness when using a .Rproj file.

Open .Rproj

In the RStudio IDE, open the .Rproj file in the repo. Project files will automatically set our working directory–in this case, the root of the directory. No need for setwd() and dealing with file paths!

After opening the .Rproj file, you’ll see some changes to your IDE. Your console and Files pane will reflect the new working directory, and the project name is listed in the top right corner.

To close out of the project, click the project name at the top right corner and select Close Project. On the day of the session, you can access the dropdown in that area of the IDE and select intro-code-org.

Install

If the following packages have not been installed, install the following by running the following code snippet in the console of your RStudio IDE. Ignore any warnings regarding Rtools and if you are asked to install from sources which needs compilation, click ‘No’.

install.packages(c('tidyverse', 'here'))

Test

Test to make sure you can read csvs from the CHAS dataset that was downloaded. Adjust the line below according to how you’ve stored your files in the data sub-directory.

file_01 <- read_csv(here('data', '050', 'Table9.csv'))