R for Social Scientists

Data Carpentry’s aim is to teach researchers basic concepts, skills, and tools for working with data so that they can get more done in less time, and with less pain. The lessons below were designed for those interested in working with social sciences data in R.

This is an introduction to R designed for participants with no programming experience. These lessons can be taught in a day (~ 6 hours). They start with some basic information about R syntax, the RStudio interface, and move through how to import CSV files, the structure of data frames, how to deal with factors, how to add/remove rows and columns, how to calculate summary statistics from a data frame, and a brief introduction to plotting.

Getting Started

Data Carpentry’s teaching is hands-on, so participants are encouraged to use their own computers to ensure the proper setup of tools for an efficient workflow.

These lessons assume no prior knowledge of the skills or tools.

To get started, follow the directions in the “Setup” tab to download data to your computer and follow any installation instructions.

Prerequisites

This lesson requires a working copy of R and RStudio.
To most effectively use these materials, please make sure to install everything before working through this lesson.

For Instructors

If you are teaching this lesson in a workshop, please see the Instructor notes.

Schedule

Setup Download files required for the lesson
00:00 1. Before we Start How to find your way around RStudio?
How to interact with R?
How to manage your environment?
How to install packages?
00:40 2. Introduction to R What data types are available in R?
What is an object?
How can values be initially assigned to variables of different data types?
What arithmetic and logical operators can be used?
How can subsets be extracted from vectors?
How does R treat missing values?
How can we deal with missing values in R?
02:00 3. Starting with Data What is a data.frame?
How can I read a complete csv file into R?
How can I get basic summary information about my dataset?
How can I change the way R treats strings in my dataset?
Why would I want strings to be treated differently?
How are dates represented in R and how can I change the format?
03:20 4. Data Wrangling with dplyr and tidyr How can I select specific rows and/or columns from a dataframe?
How can I combine multiple commands into a single command?
How can create new columns or remove existing columns from a dataframe?
How can I reformat a dataframe to meet my needs?
04:40 5. Data Visualisation with ggplot2 What are the components of a ggplot?
How do I create scatterplots, boxplots, and barplots?
How can I change the aesthetics (ex. colour, transparency) of my plot?
How can I create multiple plots at once?
06:35 6. Processing JSON data What is JSON format?
How can I convert JSON to an R dataframe?
How can I convert an array of JSON record into a table?
07:20 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.