Functions

function() and return.

function() and return(). Last expression is returned.

Goal

Write greet and a units total.

greet <- function(name) {
  paste("Hello,", name)
}
print(greet("Nairobi"))
total <- function(units, price) {
  units * price
}
print(total(12, 40))
label <- function(city = "Nairobi") {
  paste(city, "kiosk")
}
print(label())
print(label("Kisumu"))
add <- function(a, b) {
  return(a + b)
}
print(add(8, 5))