Skip to content
Prev 318866 / 398521 Next

Generating unique filenames.

Hello,
On Mar 6, 2013, at 9:20 AM, Sahana Srinivasan wrote:

            
I think you are looking for the paste() or the newish paste0() function to assemble the parts of your filename.  In the example below I make a unique name out of a timestamp and a path.  You might have a different unique name to use instead of timestamp.  Note, use file.path() to build up filename that includes a path description.

path <- "/my/own/path"
appendage <- ".zsc.txt"
string <- format(Sys.time(), format = "%Y-%j-%H%M%S")
outputFile <- file.path(path, paste0(string, appendage))
write.table(x, file = outputFile) 

Cheers,
Ben
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org