3.3 Functions

At the core of R are functions that “do things” based on your input. The basic structure is

  • object = functionname(argument1=value,argument2=value,...)

The structure has the following components

  • object: Output of the function will be assigned to object.
  • functionname: Name of the system function. You can also create and use your own functions. More about this later.
  • argument: Arguments are function specific.
  • value: The value you want a particular argument to take.

If a function is executed without an specific assignment, the output will be displayed in the console window. Before using a function, read the documentation. Many functions have default settings. Be aware of default values. In most cases, those defaults are set to values that satisfy most uses. For example, consider the help file for the function t.test.

  • t.test(x,y=NULL,...,mu=0,conf.level=0.95,...)

For this function we have the following default values

  • y=NULL
  • mu=0
  • conf.level=0.95