R (programming language): Difference between revisions

Content deleted Content added
m CE
Structure of a function: Clarified comments in the example code
Line 271:
 
The following is an example of creating a function to perform an arithmetic calculation:
<syntaxhighlight lang="r"># The function's input parameters are x and y.
# The function, being named f, returns a linear combination of x and y.
f <- function(x, y) {
z <- 3 * x + 4 * y
 
# An explicit return() statement is optional,--it could be replaced with simply `z` in this case.
return(z)
}
 
# AlternativelyAs an alternative, the last statement executed isin implicitlya function is returned implicitly.
f <- function(x, y) 3 * x + 4 * y</syntaxhighlight>