Exercises to Accompany TeachingWithR Workshop

Exercises to Accompany TeachingWithR Workshop

Matthew Beckman & Justin Post June 25, 2021

Part 2. Import Data


2.1 Packages


2.2 Data Intake: BabyNames

Use the spreadsheet view to answer the following:


2.3 Data Intake: BabyNamesSupp

The file “BabyNameSupp.csv” includes a few years of more recent data to augment the BabyNames data. Run the starter code shown below to read the data and complete the tasks.

Important: The starter code will produce a warning message! Don’t worry, it’s part of the exercise!

# starter code for BabyNamesSupp 
library(tidyverse)

BabyNamesSupp <- 
  read_csv("https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv")
## Warning: 84619 parsing failures.
##   row col           expected actual                                                                 file
## 19208 sex 1/0/T/F/TRUE/FALSE      M 'https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv'
## 19209 sex 1/0/T/F/TRUE/FALSE      M 'https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv'
## 19210 sex 1/0/T/F/TRUE/FALSE      M 'https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv'
## 19211 sex 1/0/T/F/TRUE/FALSE      M 'https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv'
## 19212 sex 1/0/T/F/TRUE/FALSE      M 'https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv'
## ..... ... .................. ...... ....................................................................
## See problems(...) for more details.

At this point, we aren’t attempting to prepare the BabyNamesSupp data for analysis. We’re just reading it into the R environment and making observations. We’ll be using these data again in later exercises, so we will make the necessary corrections at that point.


2.4 Help Documentation for Data Sets

Search “RStudio >> Help” to learn about the data…


2.5 Data for 2020 (Challenge)

Task 1: Want to include 2020 data too? See if you can locate it, read the data into R, and review the data intake (hint: BabyNames help documentation includes a source to investigate).

Again, we aren’t attempting to process the 2020 data yet. We’re just reading it into the R environment and making observations about that process. We’ll be using this data again later in the exercises, so we will make the necessary corrections at that point.


Part 3. R Markdown

Note: you might hang onto the RStudio default text provided in the new R Markdown file for the moment… it’s packed with tiny examples that will come in handy!

[coming up next…]