Back to .md Directory
layout: default
CSSS 508
Introduction to R for Social Scientists
University of Washington
Important links
- Zoom Meeting for Lectures
- 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
Helpful resources:
- 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
tidyversecollection 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.
- The Epidemiologist R Handbook, an online textbook introducing modern R approaches for epidemiology.
Weekly lecture notes and links:
1. RStudio and R Markdown
- Slides for Lecture 1: Course logistics, R/RStudio, and R Markdown
- Lecture Video for Lecture 1, recorded March 31st, 2021
- Homework 1:
- 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
prettydocpackage for nicer looking RMarkdown themes - Presentations in RStudio for simple presentations
- Xaringan for advanced presentations
panderdocumentation for making tables, etc.- Shapes and line types in base R
- Color names (PDF) in base R
2. Visualizing Data
- Slides for Lecture 2: Plotting with
ggplot2 - Lecture Video for Lecture 2, recorded April 7th, 2021
- Homework 2:
- Homework 2 Instructions
- Homework 2 Example: HTML, RMD
- Lab 2 Video: Zoom, YouTube
- Reading: Visualization chapter in R for Data Science
ggplot2Websiteggplot2Cheat Sheet- The ggplot Flipbook by Gina Reynolds
- Cookbook for R graph reference
- R graph catalog at UBC
ggplot2add-onsggthemespackagecowplotpackage for publication ready graphs, multiple plots in single image, etc.gganimatepackage 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
3. Manipulating and Summarizing Data
- Slides for Lecture 3: Manipulating and summarizing data with
dplyr - Lecture Video for Lecture 3, recorded April 14th, 2021
- Homework 3:
- Homework 3 Instructions
- nycflights13 documentation
- Homework 3 Example: HTML, RMD
- Lab 3 Video: Zoom, YouTube
- Reading: Data Transformation chapter in R for Data Science
- A cautionary tale about Excel
dplyrstuff:dplyrcheatsheets with diagrams to help you remember functions- Introduction to
dplyr - Window functions in
dplyr - Joining data in
dplyr - More advanced joins:
sqldffor easy SQL in R
4. Understanding R Data Structures
- Slides for Lecture 4: R data structures
- Lecture Video for Lecture 4, recorded April 21st, 2021
- Homework 4 (two options, complete one):
- 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
- Lab 4 Video: Zoom, YouTube
- Homework 4: R Data Structures (Less Advanced)
- Setting up swirl for practice
- Reading: Data Structures chapter in Advanced R
5. Importing, Exporting, and Cleaning Data
- Slides for Lecture 5: Data import, export, and cleaning
- Lecture Video for Lecture 5, recorded April 28th, 2021
- Homework 5, Part 1:
- Homework 5: R Markdown template (you will download this, fill in and submit on Canvas)
- Homework 5: HTML Document
- 2016 general election voting data for King County (60 MB download; save, don't load in browser!)
- Lab 5 Video: Zoom, YouTube
- Data in-class:
- Data import and export:
readrdocumentation- Column types in readr
- Using
dput()when asking for help readxlandwritexlpackages 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)
qualtricsAPI package andRmonkeyfor Survey Monkey
- Tidying:
tidyrvignette- Tidy genomics (a walkthough of tidy data preparation and analysis)
- Dates and times:
- Factors:
6. Using Loops
- Slides for Lecture 6: Loops
- Lecture Video for Lecture 6, recorded May 5th, 2021
- Homework 5, Part 2:
- Homework 5, Part 2: R Markdown template (you will download this, fill in and submit on Canvas)
- Homework 5, Part 2: HTML Document
- Homework 5, Part 2 Key: HTML, RMD
7. Writing Functions
- Slides for Lecture 7: Vectorization and writing functions
- Lecture Video for Lecture 7, recorded May 12th, 2021
- Homework 6, Part 1:
- 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
purrrfor vectorization by Jenny Bryan.
8. Working with Text Data
- Slides for Lecture 8: Working with strings and character data
- Lecture Video for Lecture 8, recorded May 19th, 2021
- Homework 6, Part 2:
- Homework 6, Part 2: RMD
- Homework 6, Part 2 Key: HTML, RMD
- Data In-Class:
- RStudio Cheat Sheet for Strings
stringrvignette- Site for regular expression testing with a good cheatsheet and hover explanations
- Blog post explaining
paste()for combining strings
9. Working with Geographical Data
- Slides for Lecture 9: Mapping with
ggplot2andsf - Lecture Video for Lecture 9, recorded May 26th, 2021
- Optional Homework 7:
- Homework 7: R Markdown template
- Homework 7: HTML File
- Seattle restaurant inspection data since 2012 (Rdata file) from King County
- Homework 7 Key: RMD, HTML
- Suggested text: Applied Spatial Data Analysis with R by Bivand et al.
- RSpatial.org: Massive resource for spatial analysis in R
ggmappackage examples- More in depth
ggmapexamples ggrepelpackage vignettesfVignette: OverviewsfHome Page- Tyler Morgan Wall's 3D Mapping and Visualization Masterclass
10. Reproducibility and Model Results
- Slides for Lecture 10: Reproducibility and model results
- Lecture Video for Week 10, recorded June 2nd, 2021
- 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:
- Overleaf online LaTeX editor
12. Working with Social Media Data (Out of Date)
- 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
rvestfor harvesting web data:tmpackage for text mining:tmvignette- Slides by Yanchang Zhao on
tmand Twitter data tidytextfor tidy text analysisquantedapackage for another set of tools
- Social media data extraction tools:
twitteRpackage for accessing Twitter in R- Setting up API keys and secrets
twitteRfunctionsstreamRfor the streaming Twitter APIRfacebook
- Shiny for interactive R apps
This project is maintained by clanfear and includes materials from rebeccaferrell with permission.
Related Documents
RUBRIC.md
Judging Rubric
**AI for Social Good Hackathon – SUST 2026**
aievalworkflow
0
2
rudra496RUBRIC.md
Single Page Applications Sprint Challenge
The sprint challenge is your chance to independently work through material and build on what you learned this week. In today's project you will build a form for Lambda Eats, a website designed to bring food to hungry coders.
ai
0
0
bloominstituteoftechnologyRUBRIC.md
Course syllabus
{: .no_toc .text-delta }
ai
0
0
ethan-campbell