Clearing out old data

By default, S+ store the data you read in or create in a directory called .Data under your home directory. You can see how much stuff is in there by typing

ls -as ~/.Data

at the UNIX command line. This list all the files with size in kilobytes. Since no data is ever removed unless you intervene, the .Data directory can eventually take up you whole disk quota. Furthermore, old variables you have created may confuse current analyses. Within S+ you remove the entire contents of the .Data directory, by

> remove(objects())

although this is somewhat extreme as this will even remove the .First function that you may have created to initialize your session. Generally, I only want to save S+ functions long term in the .Data directory. Here is an S+ function that removes everything except the functions:

houseclean <- function()
{
	a <- objects.summary()
	remove(row.names(a)[a$sto != "function"])
}
After pasting this in, execute it by

houseclean()

Other organizational tips

  1. Create subdirectories e.g.
          mkdir myproject
          cd myproject
          mkdir .Data
          Splus
          
    This Splus session will use the .Data file in your subdirectory .Data to store data. Any new S+ sessions will use a .Data directory in the current directory if it exists. This is a good way to keep data from different projects apart and makes clean-up easier.
  2. Create a special directory to store all your own S+ functions and use the attach() function to access them. This helps avoid accidentally deleting or overwriting your own functions.