A function in R is a reusable block of code created with the function keyword and assigned to a name.