R TutorialLesson 16Free preview
R Functions
This lesson is part of R · All levels
Summary
This lesson reviews the creation of custom functions in R using the keyword 'function'. The function helps to wrap up the logic of the analysis that can be reused. The developer will study function parameters, default arguments, return values through 'return()' or last-line expressions, as well as the concept of variable scope.
Key points
- Functions are created by syntax: 'name_function <- function(param1, param2) {...}'
- Supports an automated default argument if the caller does not provide it
- The value of the last line expression is automatically returned, or explicitly by 'return()'
- Supports special three-point argument '...' (ellipsis) to pass on additional parameters
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.