You must be the tidiest S+ user on the planet! I generally only delete
objects from my working chapter when it becomes too large, like 50MB+.
You can easily achieve what you want.
Use the .Last function to automatically execute code when S+ exits
normally (see the help menu)
Something like
.Last <- function(){
Objects.to.remove <- ls(pat="*"))
Objects.to.keep<- c('obj1','obj2' etc)
rm(setdiff(Objects.to.remove, Objects.to.keep))
}
You could also modify the search string in ls() to not pick up the
objects you want to keep if you use a rigid naming convention for your
kept objects.
You could also make a variable called Objects.to.keep and maintain it so
that you don't have to edit .Last when you have new variables that you
wish to keep.
You can also search on the type of object, the size, or the date, so for
example you could automatically remove objects more than 1 week old
(although this will take a bit more code to achieve using the
objects.summary function and some date conversion).
Personally I think you are being too tidy. S+ will quite happily run
with tens of MB of variables in your working chapter. Problems can occur
if you store too many objects (>1000, but that is another LONG story),
but the total size is only important if you are running out of memory. I
think that most of us just periodically clean up our working chapters
when they get too large or we have a major change in project. You can
use the object browser to manually delete objects, sorted by name, size,
date etc
Michael
branz logo
MICHAEL CAMILLERI BSc, MSc, PhD
BUILDING PHYSICIST
T +64 4 237 1170
DDI +64 4 237 1174
PRIVATE BAG 50908
PORIRUA CITY 5240
WWW.BRANZ.CO.NZ
-----Original Message-----
From: Dave Evens [mailto:devens8765@yahoo.com]
Sent: Monday, 7 May 2007 11:42 p.m.
To: s-news@lists.biostat.wustl.edu
Subject: permanent boolean variables
Dear S+ users,
I generally create lots of variables during an S+
session that are disgarded at the end of a session
using:
rm(list=ls(pat="*"))
However, I would like to create a few boolean
variables that are retained even after typing the
above line. I would like these variables to be dynamic
in the sense that the contents can be updated during
an S+ session and saved for the next session.
I've looked at the ".Last.value" variable but it
doesn't save the contents of my boolean variable after
finishing a session. Is this type of thing possible?
Many thanks in advance.
Regards,
Dave
________________________________________________________________________
____________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/
|