R for Sport Scientists – Fundamentals Course
Lecture 6: Functions
Sooner or later, you will stumble on a repeatable code, probably a code that can have adjustable parameters. That is when the functions come into play. Functions simplify your code (to avoid repetition), make it modular, easy to modify and spot errors, and easier to read.
This lecture will teach you how to write your functions in R. R is a functional language, and everything that happens in R is a function call (and everything that exits in R is an object – thus, functions are objects too). R language has rich features for writing, calling, and utilizing functions.
I have divided this lecture into four videos covering a wide range of functions fundamentals – from function components to writing infix functions.
As the final task of this R for Sports Scientists Fundamental course, we will expand the “guessing game” to involve additional parameters and to be written in the function form.