3.3 Functions in R

Functions operate on objects. Call on a function by using the name of the function followed by parenthesis, within which are the arguments the function takes, i.e. SomeFunction(args). Each function has its own set of arguments that tell it what object(s) to act on and what to do with them.

For example: the concatenate function c(item1,item2,...) combines a series of elements into a single (vector) object, and takes as its arguments the elements to be included.

  c(1,2,3,4)   # combine integers
## [1] 1 2 3 4
  a = 1:4      # create new objects, a and b         
  b = 5:7
  
  c(a,b)       # combine objects
## [1] 1 2 3 4 5 6 7