Chapter 2 Advanced R Programming

This course covers advanced topics in R programming that are necessary for developing powerful, robust, and reusable data science tools. Topics covered include functional programming in R, robust error handling, object oriented programming, profiling and benchmarking, debugging, and proper design of functions. Upon completing this course you will be able to identify and abstract common data analysis tasks and to encapsulate them in user-facing functions. Because every data science environment encounters unique data challenges, there is always a need to develop custom software specific to your organization’s mission. You will also be able to define new data types in R and to develop a universe of functionality specific to those data types to enable cleaner execution of data science tasks and stronger reusability within a team.

The learning objectives of the chapter are:

  • Describe the control flow of an R program
  • Write a function that abstracts a single concept/procedure
  • Describe functional programming concepts
  • Write functional programming code using the purrr package
  • Manipulate R expressions to “compute on the language”
  • Describe the semantics of R environments
  • Implement exception handling routines in R functions
  • Design and Implement a new S3, S4, or reference class with generics and methods
  • Apply debugging tools to identify bugs in R programs
  • Apply profiling and timing tools to optimize R code
  • Describe the principles of tidyverse functions