R4WRDS Intermediate Course

Increasing your efficiency with reproducible workflows in R


Who is this course for?

What makes an Intermediate R user? This course is most relevant and targeted at folks who:


Why R?

R is an open-source language for statistical computing and a general purpose programming language. It is one of the primary languages used for data science, modeling, and visualization.


What will you learn?

In this course, we will move more quickly, assume familiarity with basic R skills, and also assume that the participant has working experience with more complex workflows, operations, and code-bases. Each module in this course functions as a “stand-alone” lesson, and can be read linearly, or out of order according to your needs and interests. Each module doesn’t necessarily require familiarity with the previous module.

This course emphasizes:

(ref:AHRemoteR) Artwork by @allison_horst

(ref:AHRemoteR)

Figure 1: (ref:AHRemoteR)

Course Modules

  1. Check/Update R/RStudio and Packages
  2. Version Control with git
  3. Project Management and workflows
  4. Interactive visualization
  5. Simple shiny
  6. Iteration and functional programming
  7. Parameterized reports
  8. Advanced spatial R and mapmaking: I
  9. Advanced spatial R and mapmaking: II


Project Setup and Data

All data used in this course is expected to live in a /data subfolder in a project directory.

Create a New Project

We will be working in an project using RStudio. We can create a new project file (intermediate_r4wrds.Rproj), in a few different ways. Directly from RStudio (detailed in the introductory project management module), or via the command line. We can use touch intermediate_r4wrds.Rproj (MacOS/Linux) or echo > intermediate_r4wrds.Rproj (Windows) in the root project directory.

To complete code exercises and follow along in the course, you will create a /data subfolder, and a /scripts subfolder to store .R scripts, which we recommend naming by module.

Your project directory structure should look like this (note the position of the /data subfolder):

.
├── scripts
│   ├── module_01.R
│   └── module_02.R
│   └── ...
├── data
│   ├── gwl.csv
│   └── polygon.shp
│   └── ...
└── intermediate_r4wrds.Rproj

Download Data

Once a RStudio project has been created we can download the data in in a few ways:

  1. Download to a data folder in your project from a Github repository:
    # downloads the data.zip file to the `data` directory
    dir.create("data")
    download.file("https://github.com/r4wrds/r4wrds-data-intermediate/raw/main/data.zip", destfile = "data/data.zip")

    # unzip the data:
    unzip(zipfile = "data/data.zip")

    # if get resulting __MACOSX folder (artifact of unzip), remove:
    unlink("__MACOSX", recursive = TRUE)
  1. Downloaded and unzipped from OSF

Once data have been downloaded and moved to a data folder, or downloaded directly into the project, we are ready to roll!


Workshop Overview

We will follow the SFS Code of Conduct throughout our workshop.


Source content

All source materials for this website can be accessed at the r4wrds Github repository.


Attribution

Content in these lessons has been modified and/or adapted from Data Carpentry: R for data analysis and visualization of Ecological Data, the USGS-R training curriculum here, the NCEAS Open Science for Synthesis workshop here, Mapping in R, and the wonderful text R for data science.


Next module:
1. Updating R


site last updated: 2023-05-18 19:59

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/r4wrds/r4wrds, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".