Introduction to R for Social Scientists: A Tidy Programming Approach introduces the Tidy approach to programming in R for social science research to help quantitative researchers develop a modern technical toolbox. The Tidy approach is built around consistent syntax, common grammar, and stacked code, which contribute to clear, efficient programming. The authors include hundreds of lines of code to demonstrate a suite of techniques for developing and debugging an efficient social science research workflow. To deepen the dedication to teaching Tidy best practices for conducting social science research in R, the authors include numerous examples using real world data including the American National Election Study and the World Indicators Data. While no prior experience in R is assumed, readers are expected to be acquainted with common social science research designs and terminology.
Whether used as a reference manual or read from cover to cover, readers will be equipped with a deeper understanding of R and the Tidyverse, as well as a framework for how best to leverage these powerful tools to write tidy, efficient code for solving problems. To this end, the authors provide many suggestions for additional readings and tools to build on the concepts covered. They use all covered techniques in their own work as scholars and practitioners.
Why This Book?
Why the Tidyverse?
What tools are needed?
How This Book Can be Used in a Class
Plan for the Book
Scripting with R
Setting Up an R Project
Loading and Using Packages and Libraries
Where to Get Help
3. Data Management and Manipulation
Loading Our Data
Grouping and Summarizing Your Data (and Using “the Pipe”)
Creating New Variables
Combining Data sets
Basic Descriptive Analysis
Tidying a Data Set
Saving Your Data Set for Later Use
Saving Your Data Set Details for Presentation
4. Visualizing Your Data
The Global Data Set
The Data and Preliminaries
Combining Multiple Plots
Saving Your Plots
5. Essential Programming
Making your Code Modular
The map_*() Family from purrr
6. Exploratory Data Analysis
Putting it All Together: Skimming Data
7. Essential Statistical Modeling
Loading and Inspecting the Data
Chi-square Test for Contingency Tables
Ordinary Least Squares Regression
Binary Response Models
8. Parting Thoughts
Continuing to Learn with R
Where To Go From Here