Context:  I'm relatively new to R and am working with very large datasets.

General problem:  If working on a dataset requires that I produce more than
two objects of roughly the size of the dataset, R quickly uses up its
available memory and slows to a virtual halt.

My tentative solution:  To save and remove objects as they're created, and
load them when I need them.  To do this I'm trying to automatically
generate file names derived from these objects, and use these in save().

My specific question to the list:  How do I capture the string that names
an object I want to save, in such a way that I can use it in a function
that calls save()?

For example, suppose I create a matrix and then save it follows:
> mat<-matrix(1:9,3,3)
> save(mat, file="matfile")
Then I get a file of the kind I'd like: the command 'load("matfile")'
retrieves the correct matrix, with the original name 'mat'.

Further, if I instead save it this way:
> objectname<-"mat"
> save(list=ls(pattern=objectname), file="matfile")
then I get the same positive result.

But now suppose I create a function
> saveobj <- function(objectname,objectfile)
+   {
+     save(list=ls(pattern=objectname),file=objectfile);
+     return()};
Then if I now try to save 'mat' by
> matname<-"mat"
> saveobj(matname,"matfile")
I do not get the same result; namely, the command 'load("mat")' retrieves
no objects.  Why is this?


I'd be grateful for any help on either my specific questions, or
suggestions of a better ways to address the issue of limited memory.

Thanks,
David Romano

	[[alternative HTML version deleted]]

