Course website for CSSS508: Introduction to R for Social Scientists

University of Washington- Canvas Page (enrolled students only)
- Syllabus
- Homework Instructions and grading rubric.
- Peer Review Instructions and suggestions for reading code.
- Class Mailing List
- Class Slack Channel
- R and RStudio Installation Instructions
- Enabling compilation of packages
- How to Read an R Help Page

- R for Data Science online textbook by Garrett Grolemund and Hadley Wickham. One of many good R texts available, but importantly it is free and focuses on the
`tidyverse`

collection of R packages which form the backbone of this course. - Advanced R online textbook by Hadley Wickham. A great source for more in-depth and advanced R programming.
- Introduction to R Workshop, recorded Oct. 11, 2018, with companion webpage.
- Intermediate R Workshop, recorded Jan. 31, 2019, with companion webpage.
- What They Forgot to Teach You About R by Jenny Bryan and Jim Hester. Great information on best practices for managing projects and R itself.
- Teacups, Giraffes, and Statistics, an illustrated and interactive introduction to R and statistics.

- Slides for Lecture 1: Course logistics, R/RStudio, and R Markdown
- Lecture Video for Lecture 1, recorded April 3rd, 2019
- Homework 1: Due at 11:59PM on October 1st
- Homework 1 Instructions
- Homework 1 Example #1: HTML, RMD
- Homework 1 Example #2: HTML, RMD

- Get R
- Get RStudio
- R Markdown Installation - Also has LaTeX installation instructions
- Introduction to R Markdown
- RMarkdown documentation
- HTML document options (global formatting, etc.)
- PDF document options (requires LaTeX installation to output PDFs)
- Word document options (but please do not use Word output for this class!)

- R Markdown: The Definitive Guide by Xie, Allaire, and Grolemund, a comprehensive textbook on R Markdown.
- Useful RStudio cheatsheets on R Markdown, RStudio shortcuts, etc.
- Information on the
`prettydoc`

package for nicer looking RMarkdown themes - Presentations in RStudio for simple presentations
- Xaringan for advanced presentations
`pander`

documentation for making tables, etc.- Shapes and line types in base R
- Color names (PDF) in base R

- Slides for Lecture 2: Plotting with
`ggplot2`

- Lecture Video for Lecture 2, recorded April 10th, 2019
- For second half, see last term’s recording, recorded October 3rd, 2018

- Homework 2: Due at 11:59PM on October 8th
- Homework 2 Instructions
- Homework 2 Example: HTML, RMD

- Reading:
**Visualization chapter in R for Data Science** `ggplot2`

documentation`ggplot2`

Cheat Sheet- The ggplot Flipbook by Gina Reynolds
- Cookbook for R graph reference
- R graph catalog at UBC
`ggplot2`

add-ons`ggthemes`

package`cowplot`

package for publication ready graphs, multiple plots in single image, etc.`gganimate`

package for easy animations (saving GIFs requires ImageMagick or GraphicsMagick)

- Hadley Wickham on the grammar of graphics
- Tufte in R (if that’s your sort of thing)
- Recommended text: Data Visualization: A Practical Introduction by Kieran Healy

- Slides for Lecture 3: Manipulating and summarizing data with
`dplyr`

- Lecture Video for Lecture 3, recorded April 17th, 2019
- Homework 3: Due at 11:59PM on October 15th
- Homework 3 Instructions
- nycflights13 documentation
- Homework 3 Example: HTML, RMD

- Reading:
**Data Transformation chapter in R for Data Science** - A cautionary tale about Excel
`dplyr`

stuff:`dplyr`

cheatsheets with diagrams to help you remember functions- Introduction to
`dplyr`

- Window functions in
`dplyr`

- Joining data in
`dplyr`

- More advanced joins:
`sqldf`

for easy SQL in R

- Slides for Lecture 4: R data structures
- Lecture Video for Lecture 4, recorded April 24th, 2019
- Homework 4 (two options, complete one): Due at 11:59PM on October 22nd
- Homework 4: R Data Structures (Less Advanced)
- Homework 4: R Data Structures, R Markdown template (you will download this, fill in and submit on Canvas)
- Homework 4: R Data Structures, HTML Document
- Homework 4: Data Structures, Key: HTML, RMD

- Homework 4: Linear Regression (More Advanced)
- Homework 4: Linear Regression, R Markdown template (you will download this, fill in and submit on Canvas)
- Homework 4: Linear Regression, HTML Document
- Homework 4: Linear Regression, Key: HTML, RMD

- Homework 4: R Data Structures (Less Advanced)
- Setting up swirl for practice
- Reading:
**Data Structures chapter in Advanced R**

- Slides for Lecture 5: Data import, export, and cleaning
- Lecture Video for Lecture 5, recorded May 1st, 2019
- Homework 5, Part 1 due at 11:59 PM on October 29th
- Homework 5: R Markdown template (you will download this, fill in and submit on Canvas)
- Homework 5: HTML Document
- Homework 5: Key: HTML, RMD

- 2016 general election voting data for King County (60 MB download; save,
*don’t load in browser*!)

- Data in-class:
- Data import and export:
`readr`

documentation- Column types in readr
- Using
`dput()`

when asking for help `readxl`

and`openxlsx`

packages for Excel

- General data access and cleaning:
- New York Times article on “data janitor” work
- Quartz guide to bad data: a must read!
- Lots of resources on survey data sources and analysis in R
- rOpenSci (many packages for accessing particular data sources in R)
`qualtrics`

API package and`Rmonkey`

for Survey Monkey

- Tidying:
`tidyr`

vignette- Tidy genomics (a walkthough of tidy data preparation and analysis)

- Dates and times:
- Factors:

- Slides for Lecture 6: Looping with
`for()`

loops - Lecture Video for Lecture 6, recorded May 9th, 2019
- Homework 5, Part 2 due at 11:59 PM on TBD
- Homework 5: R Markdown template (you will download this, fill in and submit on Canvas)
- Homework 5: HTML Document
- Homework 5, Part 2 Key: HTML, RMD

- Slides for Lecture 7: Vectorization and writing functions
- Lecture Video for Lecture 7, recorded May 16th, 2019
- Homework 6, Part 1 due at 11:59 PM on TBD
- Homework 6, Part 1: R Markdown template
- Pronto! bike share data from fall 2014 through fall 2015
- Homework 6, Part 1 Key: HTML, RMD

- The R Inferno by Patrick Burns [PDF]: “Circles” 2, 3, and 4 are relevant after this week’s material, and Circle 8 covers a lot of miscellaneous R weird things that may trip you up.
- Reference material on writing functions with lots of examples
- Code style guide for writing functions, etc.
- R, the master troll of statistical languages (to read if you feel a bit frustrated!)
- Tutorial on
`purrr`

for vectorization by Jenny Bryan.

- Slides for Lecture 8: Working with strings and character data
- Lecture Video for Lecture 8, recorded May 22nd, 2019
- Homework 6, Part 2 due at 11:59 PM on TBD
- Homework 6, Part 2: RMD
- Homework 6, Part 2 Key: HTML, RMD

- Data In-Class:
- RStudio Cheat Sheet for Strings
`stringr`

vignette- Site for regular expression testing with a good cheatsheet and hover explanations
- Blog post explaining
`paste()`

for combining strings

- Slides for Lecture 9: Mapping and labels in
`ggplot2`

- Lecture Video for Lecture 9, recorded May 29th, 2019
- Optional Homework 7: Due at 11:59 PM on TBD
- Homework 7: R Markdown template
- Homework 7: HTML File
- Seattle restaurant inspection data since 2012 (CSV, about 16 MB) from King County
- Homework 7 Key: HTML, RMD

- Suggested text: Applied Spatial Data Analysis with R by Bivand et al.
- RSpatial.org: Massive resource for spatial analysis in R
`ggmap`

package examples- More in depth
`ggmap`

examples `ggrepel`

package vignette`sf`

Vignette: Overview`sf`

Home Page

- Slides for Lecture 10: Reproducibility and Best Practices
- Leacture Video for Lecture 10, recorded November 28, 2018
- Reading: Good Enough Practices in Scientific Computing
- Initial Steps Toward Reproducible Research by Karl Broman
- The Plain Person’s Guide to Plain Text Social Science by Kieran Healy
- R Packages:

- Slides for Lecture 11: Tidy Model Results and Applied Data Cleaning
- Lecture Video for Lecture 11, recorded June 5th, 2019
`broom`

vignette`ggeffects`

vignette`sjPlot`

home page- Overleaf online LaTeX editor

- Slides for Lecture 12: Social media and text mining
- Lecture Video for Week 12, recorded Autumn 2017
- Twitter Apps portal
- Fabulous analysis of Trump tweets using R
- Absolute Beginner’s Guide to
`SocialMediaLab`

- Static and Dynamic Network Visualizations with R
`rvest`

for harvesting web data:`tm`

package for text mining:`tm`

vignette- Slides by Yanchang Zhao on
`tm`

and Twitter data `tidytext`

for tidy text analysis`quanteda`

package for another set of tools

- Social media data extraction tools:
`twitteR`

package for accessing Twitter in R- Setting up API keys and secrets
`twitteR`

functions`streamR`

for the streaming Twitter API`Rfacebook`

- Shiny for interactive R apps

This project is maintained by clanfear and includes materials from rebeccaferrell with permission.