R Basics Workshop (at UChicago)

I conducted an R Workshop at the University of Chicago. This post contains the materials and code adapted from a Slidify presentation. The full presentation and code can be found on this repo.

Agenda

Installing and Loading Packages Reading Data into R - using jsonlite package Reshaping Data (Wide to Long format) - using reshape2 package Data Manipulation - using dplyr package Data Visualization - using ggplot2 package

Installing Packages

install.packages("packagename")

library(packagename)

Exercise 1: Install and load these packages into the R environment

httr

jsonlite

dplyr

ggplot2

Reading Data into R

What is JSON http://fx.priceonomics.com/v1/rates/ http://fantasy.premierleague.com/web/api/elements/1/



Exercise 2: Fetch your IP address

Data Manipulation

dplyr

Key features tbl_df() %>% chaining operator Verbs select filter arrange mutate summarise



Exercise 3a: Come up with a metric for the sports dataset and use dplyr to generate it

Exercise 3b: Explain why the metric is relevant

Data Visualization

ggplot2: Grammar of Graphics Plots as objects Layering aesthetics and options



Exercise 4: Visualize the sports dataset metric

Summary

Installing and Loading packages in R

Reading data read.csv jsonlite package

Data munging using dplyr

Visualization using ggplot2

Metrics Context Relevance Communication



Resources