Block 4: Diving into Coding with R

Setup Pre-requisites:

Welcome to Block 4 of the UVic RDM Jumpstart!

In this block we’re going to really get into the nuts and bolts of coding in R. We’re first going to start by discussing how your computer sorts files and folders, and will delve into the world of file paths as a common area that people struggle with when first learning a coding language. We will then jump into R, and will look at the Tidyverse package as a great set of tools to start working with data, and will import, or “read in” our first dataset in R. We will then look at changing the column names of a dataset to match best naming practices, and will save our first dataset, which is an updated version of the original. We will then address the different data types and structures in R, and will recode a few different variables to friendlier formats, which is a very common part of data cleaning, and will save another version of our data. We will finish the session by updating our documentation to account for the new files that we have created.

Below you’ll find the overarching learning objectives for Block 4, as well as an overview of each session.

Block 4 Learning Objectives

By the end of this block, you will be able to:

  • Identify how your computer sorts information via file paths
  • Define relative and absolute file paths
  • Articulate the role of packages in R, and begin using the Tidyverse package as part of the Data Science Workflow
  • Read in data to R
  • List column names in R
  • Change column names in R
  • Describe the different data types and structures in R, and how this relates to working with a dataset
  • Check data types in R
  • Handle missing data in R
  • Recode variables in R

Block 4 Session Overviews

Session 1: File and Directory Paths

  • Definitions
    • Files
    • Directories
    • Paths
  • Navigating files and directories
  • File path exercise
  • Absolute vs. relative paths
  • Why should you care?

Session 2: First Steps in R

  • Introduce R projects as good practice for setting a working directory
  • Discuss the Tidyverse and its utility in the data science workflow
  • Install and load the Tidyverse
  • Import the project dataset into R
  • Explore the dataset using R functions
  • Change column names of the project dataset
  • Save the dataset in both .csv and .RData formats

Session 3: Data Types and Structures in R

  • Present data types and structures in R
  • Check data types of the project dataset
  • Recode variables in the project dataset
  • Accounting for missing data in R
  • Save a new version of the dataset and backup to OSF

Session 4: Updating Documentation

  • Update the project README to reflect new files