Message-ID: <Pine.A41.4.58.0402201050060.109002@homer04.u.washington.edu>
Date: 2004-02-20T18:54:15Z
From: Thomas Lumley
Subject: passing object names in a vector to save?
In-Reply-To: <200402201758390883.0AFD0B55@harry.molgen.mpg.de>
On Fri, 20 Feb 2004, wolski wrote:
> for(x in nam)
> {
> #reads the objects and assigns the names.
> assign(x,simFromEmboss(Simmatrix(),x))
> nnam<-paste(x,".rda",sep="")
> print(nnam)
> save(x,file=nnam)
> }
>
>
> I knew that it fails. (It saves object x containing a char.)
There are at least two possibilities. The specialised one is to look at
the help for save() and notice that you can specify a vector of names of
objects with the list= argument
save(list=x,file=nnam)
The more general one is to use substitute() or do.call(). For example
do.call("save",list(as.name(x),file=nnam))
-thomas