
Robert S. answered 11/22/19
R Developer and Analyst
Essentially, you create a function by giving it a name, the inputs, and the form of the output. See the code block below for an example.
```
myfun <- function(x, y) { # Set the name of your function and define the number of inputs ("formals")
(x + y)/y # This is the body of the function. Define what you want the function to compute.
}
myfun(100, 300) # == 1.333333
```
Reference: http://adv-r.had.co.nz/Functions.html