Define Custom Functions in R
In Python, we define a function using the def reserved word followed by optional parameters in parenthesis. The body of the function is indented (very important!).
This defines the function but does not execute the body of the function.
In the below example, we define a new function called greet() which will print Hello Dolly when called.
1def greet():
2 print("Hello Dolly")
3Test Your Knowledge
Check your understanding of this lesson with a short quiz.
