Reporting with Data in R
Reporting with Data in R is a series of lessons and instructions used for courses in the School of Journalism and Media, Moody College of Communication at the University of Texas at Austin. The first two versions of the book were written by Assistant Professor of Practice Christian McDonald. Assistant Professor Jo Lukito joined in teaching sections of the Reporting with Data in spring 2022.
This means the book is morphing from the voice of a single author and that might get confusing at times. In addition, Prof. McDonald uses a Mac and Prof. Lukito uses a PC, so keyboard commands and screenshot examples may flip back and forth. We’ll try to note the author and platform at the beginning of each chapter.
We are currently updating for the fall 2022 semester. Earlier versions are linked below.
R is a super powerful, open-source programming language for data that is deep with features and an awesome community of users who build upon it. No matter the challenge before you in your data storytelling, there is probably a package available to help you solve that challenge. Probably more than one.
There is always more than one way to do things in R. This book is a Tidyverse-oriented, opinionated collection of lessons intended to teach students new to programming and R for the expressed act of committing journalism. As a beginner course, we strive to make it as simple as possible, which means we may not go into detail about alternative (and possibly better) ways to accomplish tasks in favor of staying in the Tidyverse and reducing options to simplify understanding. We rarely even discuss differences from base R; Tidyverse is our default.
We will try to be consistent in the way we write documentation and lessons. But we are human, so sometimes we break our own rules, but in general keep the following in mind.
Things to DO are in ordered lists:
- Do this thing.
- Then do this thing.
Explanations are usually in text, like this very paragraph.
Sometimes details will be explained in lists:
- This is the first thing I want you to know.
- This is the second. You don’t have to DO these things, just know about them.
We will use the blockquote syntax to set off a less important aside:
Markdown was developed by JOHN GRUBER, as outlined on his Daring Fireball blog.
But sometimes those asides are important. We usually indicate that:
IMPORTANT: You really should learn how to use Rmarkdown as you will use it the whole semester, and hopefully for the rest of your life.
When you see R code in the instructions, you can roll your cursor over the right-corner and click on the copy icon to copy the code to your clipboard:
You can then paste the code inside your R chunk.
That said, typing code yourself has many, many benefits. You learn better when you type yourself, make mistakes and have to fix them. We encourage you to always type short code snippets. Leave the copying to long ones.
The first version of this book from spring 2019 is buried somewhere in the commit history, but we’ve archived other recent editions:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Let’s just say this is free on the internet. We don’t make any money from it and you shouldn’t either.
This text stands upon the shoulders of giants and by design does not cover all aspects of using R. Here are some other useful books, tutorials and sites dedicated to R. There are other task-specific tutorials and articles sprinkled throughout the book in the Resources section of select chapters.
- R for Data Science by Hadley Wickham and Garrett Grolemund.
- The Tidyverse site, which has tons of documentation and help.
- The RStudio Cheatsheets.
- R Graphics Cookbook
- The R Graph Gallery another place to see examples.
- Practical R for Journalism by Sharon Machlis, an editor with PC World and related publications. Sharon is a longtime proponent of using R in journalism.
- Sports Data Analysis and Visualization and Data Journalism with R and the Tidyverse by Matt Waite, a professor at the University of Nebraska-Lincoln.
- R for Journalists site by Andrew Tran, a reporter at the Washington Post and University of Texas alum. A series of videos and tutorials on using R in a journalism setting.