Package things into understandable chunks & reuse code easily.

Chunks

Reuse

Function basics

function_name <- function(inputs){
  commands
  return(output_value)
}
add <- function(a, b){
  total = a + b
  return(total)
}
add(2, 3)
summed <- add(2, 3)
a
b