Session 4: Learning the basics of R - Part 3

Creating your own functions: Introducing functional programming

This session teaches how to write functions and provides a challenge to write a function given a specific task.

In this session, the students will be introduced to functions in R and how they can be used to extend the functionalities of R. The students will be introduced to what functions are and how to create their own functions for specific computing and statistical analysis tasks that they require.

Further Reading

  • Wickham H and Grolemund G. Functions. In R for Data Science. https://r4ds.had.co.nz/functions.html

  • Myatt M. Exercise 2 - Manipulating objects and creating new functions. In Practical R for Epidemiologists. https://practical-r.org/exercise2.html

Teaching Material

Slides can be viewed here.

PDF version of slides can be downloaded here.

R scripts for slides available here.