Skip to Main Content

R for Beginners

Guide for the workshop Using R for Data Wrangling, Analysis, and Visualization

Pre-survey & Workshop Evaluation

Please fill out the pre-survey and evaluation to help us understand your expectations and thoughts about the workshops.

Session 1: Before We Start

Session 1: Before We Start

Content Covered

  1. R and RStudio Installation

  2. More about RStudio - interface, projects, working directory

  3. R package installation

Details

Installation for PC
  1. Download R from https://cran.r-project.org/bin/windows/base/
  2. Download RStudio at https://posit.co/download/rstudio-desktop/#download
Installation for Mac
  1. Check your version number and make sure to download the correct version of R/RStudio.

  2. Download R from https://cran.r-project.org/bin/macosx/, and select the .pkg link based on your macOS version.

  3. Download RStudio at https://posit.co/download/rstudio-desktop/#download

R & RStudio Installation Guidance
 
Relevant Links

Common Shortcuts in RStudio

Windows /Linux

Mac

Run current command/selection

Ctrl+Enter

Cmd+Enter

Show shortcuts

Alt+Shift+K

Option+Shift+K

Insert <-

Alt+-

Option+-

Comment lines

Ctrl+Shift+C

Cmd+Shift+C

Insert code section

Ctrl+Shift+R

Cmd+Shift+R

Insert %>%

Ctrl+Shift+M

Cmd+Shift+M

Session 2: Introduction to R

Session 2: Introduction to R

Content Covered

  1. Objects, functions, and comments

  2. Vectors and data types

  3. Missing data

Relevant Links

Session 3: Starting with Data

Session 3: Starting with Data

Content Covered

  1. Data SAFI

  2. Data frames and tibbles

  3. Formatting dates

Details

About the Dataset

The data used for this lesson are in the figshare repository at: https://figshare.com/articles/SAFI_Survey_Results/6262019

This lesson uses SAFI_clean.csv. The direct download link for this file is: https://ndownloader.figshare.com/files/11492171

Session 4: Data Wrangling with dplyr

Session 4: Data Wrangling with dplyr

Content Covered

  1. Select rows and/or columns from a data frame
  2. Combine multiple commands into a single command
  3. Create new columns and remove existing columns from a data frame

Session 5: Data Wrangling with tidyr

Session 5: Data Wrangling with tidyr

Content Covered

  1. Wide vs long format of dataframes
  2. Reshape a dataframe between its wide and long formats
  3. Export a dataframe to a csv file

Session 6: Data Visualization with ggplot2

Session 6: Data Visualization with ggplot2

Content Covered

  1. Fundamental elements of a ggplot graphic
  2. Create scatterplots, boxplots, and bar charts
  3. How to create multiple plots at once

Video from 2022 Session 1

Video from 2022 Session 2

Video from 2022 Session 3

Video from 2022 Session 4

Books about R and R Programming