Class 15
Functions
AGENDA
Today’s Class …
During Class …
Next Class …
Overview
Class 15
3
Julia’s Examples
Class 15
4
Julia’s Examples
Class 15
5
Benefits of Functions
Class 15
6
Parts of a function
A name
The arguments- The arguments are things that vary across calls
The body- The body is the code that’s repeated across all the calls.
Class 15
7
Parts of a function
name <- function(arguments)
{ body
}
Class 15
8
Function Example
Class 15
9
# function to add 2 numbers add_num <- function(a,b) { sum_result <- a+b return(sum_result) } # calling add_num function sum = add_num(35,34) #printing result print(sum) |