Exercises to Accompany TeachingWithR Workshop

Exercises to Accompany TeachingWithR Workshop

Matthew Beckman & Justin Post June 25, 2021


Here, we join an analysis already in progress…


Part 2. Import Data (Code Recap)


## from instructions before workshop, if needed:
# devtools::install_github("mdbeckman/dcData")

# packages
library(tidyverse)  
library(dcData)     

# data intake
data("BabyNames", package = "dcData")

BabyNamesSupp <- 
  read_csv("https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv")

# 2020 data intake was issued as a challenge task only
BabyNames2020 <-   
    read_csv("https://jbpost2.github.io/TeachingWithR/datasets/yob2020.txt", 
             col_names = FALSE)


# inspecting the data
head(BabyNamesSupp)
tail(BabyNamesSupp)

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!


3.1 Goal

We’ll be investigating the popularity of names in the US each year. Choose a few (4-5) names to investigate to you–friends, family, TV character, colleagues in the workshop!


3.2 Update yaml Header

---
title: "Add a title"
author: "Add your name"
date: "Pick a date"
output: html_document
---

3.3 Add Narrative & Code Chunk


3.4 Render Various Output Formats

R Markdown is a flexible syntax that can render the same .Rmd (text) file in different formats. If you know the syntax, you can update the output: directly in the yaml header. RStudio provides a shortcut as a (tiny) menu arrow next to the “Knit (yarn)” icon revealing a few common choices.


Part 4. Data wrangling

[coming up next…]