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.
Clone the repo https://github.com/psrc/intro-code-org onto your local drive.
Download the CHAS zip file of the 2015-2019 ACS 5-year average data
for Census counties
from here.
Extract the zipfile in the data
sub-directory of the cloned repo.
All data files will be found in data/050
.
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.
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
.
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 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.