...

/

Creating Functions

Creating Functions

In this lesson, we will learn what functions are and how to create them in the R language.

What is a Function?

A function is a set of statements that are executed together to achieve a specific goal or task.

You might remember that everything in R is an object. From this, we can conclude that a function is also an object in R language.

Syntax of a Function

An R function is created by using the keyword function. The basic syntax is as follows:

functionName <- function(argument1, argument2, ..., argumentN) 
{
   # Statements 
}
...