Introduction, workflow, setup
At least at first, it should be totally adequate to follow along with the slides I’m sharing on the screen. But I know people like to have all the materials!
Everything is available on GitHub, https://github.com/AmeliaMN/CodeYouCanBankOn /
If you are a git/GitHub user, you can fork and clone this repo. /
If you’re not, you can download everything as a zip file
I’m an Associate Professor of data science at the University of St. Thomas, and a proud R-lady. I’ve taught a ton of workshops like this over the years, from Software Carpentry to rstudio::conf to NICAR and everything in between.
The materials you’ll be seeing from me have been modified from a number of sources, including:

One huge feature of the R community is that everyone is so generous with their time, expertise, and materials. Almost everything (including this workshop!) is Creative Commons licensed, so others can remix and reuse as they see fit.
Artwork by Allison Horst
I am assuming you have a baseline familiarity with
I’ll do a little bit of review of each of those topics, but if they are totally new to you, here is some background reading to help you get caught up.
We’re going to be using the following packages, so make sure they are installed!
We’re going to strive not to be data-hoarders

Tools -> Global Options
Restore .RData into workspace at startup: unchecked
Save workspace to .RData on exit: Never
../Data/InputData/some_file.csv,
rather than
/Users/myUserName/Documents/Project/Data/InputData/some_file.csv
One way to avoid absolute file paths is to use RStudio Projects. Projects are basically directories (folders) that RStudio maintains a bit more information about.
To make a project, go to File -> New Project. You can either make a project out of an existing directory, or RStudio will create the directory for you if you’re starting from scratch!
(if you haven’t already downloaded the materials, you could make a New Project from Version Control!)
The TIER Protocol is one suggested organizational method

You need to name your files. Names should strive to be:
NO
YES
Via Jenny Bryan
There used to be several competing style guides for R code style, but many (most?) people have coalesced around the tidyverse style guide. Some organizations have modifications of the guide, like Google’s R style guide.
Tidyverse style uses snake_case rather than CamelCase.
Generally, variable names should be nouns and function names should be verbs. Strive for names that are concise and meaningful (this is not easy!).
.RprofileThe usethis package allows you to add default information about you that will be used in package development.
Edit your .Rprofile with usethis::edit_r_profile:
to set the following options….
.Rprofile.RprofileLoad devtools and testthat on start up
Restart R for these to take an effect.
We’re going to be using some data from FRED as we work, so we need to go get it first.
This package makes it easier to get FRED data, but it does require an API key. Request an API key


add your API key like this (replace with your own key)
FRED_API_KEY='abcdefghijklmnopqrstuvwxyz123456'
Save .Renviron
Restart R
From FRED
We’d rather not be using the API every time we want to play with this data, so let’s save it as a local CSV.
When I save out data, I always do a quick test to make sure I did it right!
Looks good!
Let’s do some quick EDA. What does the tomato price data look like?
I’d also like data on the average price of bacon (sliced), and iceberg lettuce. Can you find those API endpoints and grab the data for the past ten years on them?
Save the datasets as .csv files so we can access them without hitting the API again.