Matthew Beckman & Justin Post June 25, 2021
[omitted for brevity…]
## 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)
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!
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!
Matt has chosen the names of his family members: Matthew, Sarah, Eden, Jack, & Hazel.
Task 1: “Knit” the document to render the initial HTML document
Task 2: update yaml header as necessary to include an informative title, author name, & relevant date.
---
title: "Add a title"
author: "Add your name"
date: "Pick a date"
output: html_document
---
Task 3.2.2: Your yaml header should appear at the beginning of the Rmd document, but here is some example text
---
title: "What's in a Name??"
author: "Matt Beckman & Justin Post"
date: "June 25, 2021"
output: html_document
---
tidyverse
and dcData
packagesBabyNames
from dcData
packageBabyNamesSupp.csv
using read_csv( )
now()
directly from lubridate
package INLINE for the time stamp.
Task 3.3.1:
Some sample narrative text follows; note that it is simply one long line of soft-wrapped text, and no formatting of any kind is imposed:
I’ve chosen to investigate the names of each person in my immediate family: Matthew, Sarah, Eden, Jack, and Hazel. They’re my favorite people, and also my favorite names! I’m a bit torn about how I’ll include my son Jack in the analysis. His legal name is “Jon” but he is nearly always called “Jack”–the spelling of “Jon” honors our scandinavian heritage on both sides of the family, and the nickname “Jack” specifically honors his great-grandfather.
Some famous persons by each name of the family include:
Task 3.3.2
# libraries
library(tidyverse)
library(dcData)
# data intake
data("BabyNames", package = "dcData")
BabyNamesSupp <- read_csv("https://jbpost2.github.io/TeachingWithR/datasets/BabyNamesSupp.csv",
col_types = cols(sex = col_character())) # fixes `sex`
Task 3.3.3
Here’s the code I used:
This document was last modified 2021-06-25 10:27:39.
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.
output: word_document
”tinytex::install_tinytex()
output: pdf_document
output: html_notebook
output: html_document
[coming up next…]