3.2 Objects

Objects are created by assigning them a value using the object name, followed by an assignment operator (i.e. = or <-), followed by either the information they should contain or instructions for importing information from another file. Entering information without assigning it to an object simply prints the output to the console; by assigning it a name it is possible to work with it.

  1:4               # prints a sequence of integers
## [1] 1 2 3 4
  MyObject = 1:4    # assigns the sequence to a new object, myObject

To report the contents of an object, enter the object name on a line and execute that line.

  MyObject
## [1] 1 2 3 4

Objects no longer needed can be removed from the workspace using remove() In this case:

  remove(MyObject)