Re: [R] *** saving files ***

From: Wiener, Matthew <>
Date: Thu 15 Sep 2005 - 00:10:36 EST

Depending on the size of your objects, you may be able to just keep them in a list, especially as you say you will need them in the same order later.

If because of memory constraints or for some other reason you really need to have a separate file for each round, you can generate object and file names using "paste", assign the object to the name with assign, and save the file:

(warning: untested code)
for(i in 1:n){ <- paste(, i, sep = ".") <- paste(, "rda", sep = ".")  # or whatever other
file name you want
	this.obj <- my.fn.that.creates.object(my.arguments)
	assign(, this.obj)
	save(list =, file =

When retrieving the files, you can use a similar loop, but instead of using "assign", you can use "get" to retrieve the value and assign it to another variable. Or, in interactive use, you know the name so you can refer to the variable.

Hope this helps,


-----Original Message-----
[] On Behalf Of Shahrokh Keiwani Sent: Wednesday, September 14, 2005 9:43 AM To:
Subject: [R] *** saving files ***


   I need help :o(    

   I want that my function saves result files in a for()-loop while it runs    automatically.    

   the filenames must be saved like:    

   file_1 -> for 1. result

   file_2 -> for 2. result

   file_3 -> for 3. result    





   file_n -> for n. result    

   the file names are the same identified by _1, _2 , _3, ... , _n    

   these files will loaded by a second function later in the same sequence    (_1 to _n).    

   how can I do that ...                     

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Wed Sep 21 02:13:30 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 17:12:33 EST