People working in the media deal with data constantly. Journalists who are interested in improving their data skills will find this book useful. The book will concentrate on teaching R and will not go into statistical details. Data sets and projects chosen for the book are especially important in the journalism market.
Introduction
Why programming?
Why R?
Is this book for you?
Get Started With R in a Few Easy Steps
What we'll cover
Download R and RStudio
A brief introduction to RStudio
Try out the console
Install packages
Additional infrastructure
Getting help with packages and functions
RStudio keyboard shortcuts
Additional files available online
Wrap-Up
Additional resources
See How Much You Can Do in a Few Lines of Code
Packages needed this chapter
What we'll cover
Simple stock market graphing
Download and graph a city's median income
So many packages!
Running functions without loading packages
Comparing one city's data to the US median
Run a remote script to make an interactive map
Bonus map: Mapping income data
Wrap-Up
Additional resources
Import Data into R
What we'll cover
Packages needed this chapter
The magic of rio
Import data from packages
What's a data frame? And what can you do with one?
Easy sample data
Exporting data
Additional resources
Basic Data Exploration
Project: Weather data
What we'll cover
Packages needed this chapter
Download this book's files
Data summaries
Data `interviews'
Slicing and dicing your data set
More sub setting with dplyr
Wrap-Up
Additional resources
Beginning data visualization
Project: More weather data
What we'll cover: How to
Packages needed this chapter
Answer questions with graphics
Easy visualizations in or lines of code
Some basic graphs
The full power of ggplot
Basic ggplot customizations
Code snippets to the rescue
Presentation-quality graphics
Comment your code
Wrap-up
Additional resources
Two or more data sets
Project: Multiple files of US airline on-time data
What we'll cover
Packages needed this chapter
Add one table to the bottom of another
What's a list, and how do operate on one?
lapply
here () you are!
Wrap-up
Exercise Answer
Additional resources
Analyze data by groups
Project: Airline on-time data analysis (cont)
What we'll cover
Packages needed this chapter
Lookup tables
Beware of missing values
Bar graph of raw data
Wrap up
Additional resources
Graphing by Group
Project: Visualizing airline on-time data
What we'll cover
Packages needed this chapter
Facets
Housing prices by state
Geofacets
Customizing colors
Color palettes
Other packages that extend ggplot functionality
Wrap-up
Additional Resources
Exercise answer
Write your own R functions
What we'll cover
Packages needed this chapter
Function basics
seq()
If-then-else
if statements for vectors
A taste of testing
Next steps for your functions
More Resources
Exercise Answer
Exercise Answer
Exercise
Maps in R
Map projects this chapter
Skills we'll cover
Importing shape files into R
Import data for mapping
An even easier way to pull US Census data
Interactive maps with tmap
Importing and joining data
Leaflet and points on a map
geocoding and R's paste () function
Time to geocode with R (or maybe without)
Mapping points with leaflet
Points and polygons on a single map
Mapping new political boundaries with leaflet
Inspiration: Washington Post investigation
Wrap-up
Additional resources
Putting it all Together: R on Election Day
Project: Election data
What we'll cover
Packages needed this chapter
Election Day preparation
Visualizing election results
Graph for a smaller set of results
plotly
Other interactive alternatives
Wrap-up
(Non-election) inspiration
Additional resources
Date calculations
Project: New York City restaurant inspections
What we'll cover
Packages needed this chapter
Get started with dates in R
Get NYC inspection data
Wrap-up
Inspiration
Additional resources
Help! My data's in the wrong format!
Project: Election results in a PDF
What we'll cover
Packages needed this chapter
Human vs machine optimizing
The raw data
Extracting data from PDFs
Tidying the data
Reshaping the data
`Long' data back to `wide'
Winners and runners-up
Wrap-up
Additional resource
Using tabulizer to unlock the City Council data
Integrate R With Your Storytelling Using R Markdown
Project: Mixing text and R code about that snow data
What we'll cover
Packages needed this chapter
R Markdown basics
Create an R Markdown document
R Markdown text syntax
R code chunks
Adding R code to run
Add an R-generated graph
Setting option options
Mixing R within text
Even more options
Repeatability with R Markdown parameters
Wrap-up
Additional resources
Simple Web scraping
Project: Download RStudio PDF cheat sheets
What we'll cover
Packages needed this chapter
Step: Follow the rules with robotstxt
Step: Get a list of links
Step: Download files
Wrap-Up
Additional resources
An R project from start to finish
Project: Local political contribution and election data
What we'll cover
Packages needed this chapter
Get the data, make it ready for analysis
Standardizing multiple versions of the same name
Making data frames
Analyzing and graphing the results
Visualizing results
Consider R Markdown
Additional resources
Additional resources
More functions, packages and tools worth a look
Stories done with R
Tutorials
Social media, communities, and Web resources
Appendix A Online: How do I
Appendix B Online: Functions
Appendix C Online: Packages