Managing Your Objects

As a typical R session progresses, you tend to accumulate a large number of objects. Various tools are available to manage them. Here, we’ll look at the following:

  • The ls() function

  • The rm() function

  • The save() function

  • Several functions that tell you more about the structure of an object, such as class() and mode()

  • The exists() function

Listing Your Objects with the ls() Function

The ls() command will list all of your current objects. A useful named argument for this function is pattern, which enables wildcards. Here, you tell ls() to list only the objects whose names include a specified pattern. The following is an example.

> ls() [1] "acc" "acc05" "binomci" "cmeans" "divorg" "dv" [7] "fit" "g" "genxc" "genxnt" "j" "lo" [13] "out1" ...

Get The Art of R Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.