Environment


An R environment or "image" is the collection of variables and functions that have been initialized in a command session.

To view the variables in the current environment use the ls()command.

To remove a specific variable in the current session use

rm(variable);

To remove all variables in the current session use

rm(list = ls());

One can save the current R environment variables by selecting the File/Save image menu item in the GUI, or by using the save command. The default file name for a data image is .RData. Note that upon exiting the R GUI, if you choose to "save the workspace image", then this image will be placed in the file .RData in the current working directory.

To load an image, one can use File/Load image in the GUI or by using the load command.


Use the options() to set environment options, e.g. such as formatting for printing output and the prompt. . See options for details.


Original Documentation: ls, rm, save, load , options

Samples


  ls()                # list the variables and functions in the current session

  rm(x)               # remove the variable from the current session

  rm(list = ls())     # removing all variables rom the current session
  

# saving the current environment in the file keepImage

  save.image(file='keepImage')    

# loading the current environment from the file keepImage

  load(file='keepImage)

UCLA Mathematics Department ©2000