Week 6 Overview

Published

2026-05-01

This week we’ll start off with a recap, and then introduce the apply() functions from Base R, and the (mostly) equivalent tidyverse options from the purrr package. We will then get into advanced function writing!

The last part of the material for this week introduces R Shiny. More info on that in the week 7 overview!

Week 6 (Optional) Additional Readings/Learning Materials

apply() family and Function Material

Advanced R Chapters

purrr

R for Data Science: Chapter 26.3.3

Week 6 Learning Objectives

Upon completion of this week, students will be able to:

  1. write an R function that has default arguments, allows for additional arguments, and returns a well-structured named object

    1. determine appropriate uses for the stop function
    2. develop a pipeable function that acts on a data frame and one that produces side effects
    3. create a custom infix function
  2. define environments including temporary environments

    1. summarize the order in which R attempts to find a requested object
    2. sketch out the R environment framework and explain the idea of lexical scoping
    3. discuss the concept of local variables and local environments as compared to global variables and environments
    4. state the naming conventions for R objects
  3. program using the “apply family” of functions and the purrr packing in R

    1. differentiate between the apply family of functions in R including, but not limited to, mapply, sapply, lapply, apply, and replicate
    2. manipulate R code that uses loops to instead use the proper apply function
    3. utilize anonymous functions in calls to the apply family of functions in R
    4. use functions from purrr to perform data manipulations
  4. describe what an anonymous function is and how it differs from other functions

Use the table of contents on the left or the arrows at the bottom of this page to navigate to the next learning material!