Effective Data Analysis Pipelines in R

Nathan Eastwood

Effective Data Analysis Pipelines in R

Nathan Eastwood
nathan.eastwood@icloud.com

About Me

Agenda

Single Script Analyses

|- ProjectName/
    |- data/
    |- output/
    |- run.R
    |- README.md

Multiple Script Analyses

|- ProjectName/
    |- data/
    |    |- raw/
    |    |- cleaned/
    |    |- prepared/
    |- output/ 
    |    |- fig/
    |    |- results/
    |- lib
    |    |- source.R
    |    |- explore.R
    |    |- prepare.R
    |    |- model.R
    |    |- evaluate.R
    |    |- utils.R
    |- run.R
    |- README.md

Problems

remake

remake Components

remake Components - The YAML File

Example

The YAML File - Packages and Source Files

Source

The YAML File - the Targets

Targets

The YAML File - the Targets

Targets

The YAML File - the Targets

Targets

comp-yaml

Visualising Your Workflow

Visualising Your Workflow

Running the Analysis

> remake::make()
[  LOAD ] 
[  READ ]                                              |  # loading sources
<  MAKE > all
[ BUILD ] transformedData                              |  transformedData <- mapNames()
[  READ ]                                              |  # loading packages
Joining, by = "carrier"
[ BUILD ] numFlights                                   |  numFlights <- numFlightsFromAirport(transformedData)
[ BUILD ] depDelay                                     |  depDelay <- meanDepartureDelayByCarrier(transformed...
[  PLOT ] figures/num_flights_per_airport.png          |  plotNumFlights(numFlights) # ==> figures/num_flights_per_airport...
[  PLOT ] figures/mean_departure_delay_per_carrier.png |  plotDepDelay(depDelay) # ==> figures/mean_departure_delay_per_ca...
[ BUILD ] report.html                                  |  render("report.Rmd")
...
[ ----- ] all

Re-running the Analysis

> remake::make()
<  MAKE > all
[    OK ] transformedData
[    OK ] numFlights
[    OK ] depDelay
[    OK ] figures/num_flights_per_airport.png
[    OK ] figures/mean_departure_delay_per_carrier.png
[    OK ] report.html
[ ----- ] all

Other Essential Tools

Other Automation Tools

Summary - Key Messages

Any Questions?

website https://nathaneastwood.github.io

Twitter @nathaneastwood_

GitHub https://github.com/nathaneastwood