R: Calling a Function

It is nothing but calling the original function with a valid number of argumentsA function can be called with or without argument and with a default value also.

We can easily call a function, we simply have to use the function’s name and provide arguments call. We can also call a function from anywhere in the environment in which the function is declared.

Syntax

function_name(arguments)

Example

new.function <- function(a)
{
    for(i in 1:a)
    {
        b <- i^2
        print(b)
    }
}
new.function(6)

Output:

[1] 1 
[1] 4 
[1] 9 
[1] 16 
[1] 25 
[1] 36