Create Unique Names for Files

DESCRIPTION:

Returns a vector of character strings that are virtually certain to be unique filenames.

USAGE:

tempfile(pattern="file") 
tempdir()

OPTIONAL ARGUMENTS:

pattern
a vector of character strings to form the beginnings of the returned filenames.

VALUE:

tempfile returns a vector of character strings giving names of files that may be used as temporary files ( pattern or the first few characters in it is followed by a number). The names are essentially certain to be unique from one call to the next.

tempdir returns the name of the directory in which temporary files will be made. Currently, the first time this is called in a session, a new directory is created and future calls to tempfile will name files in that directory. At the end of the Splus session this directory will be removed.

DETAILS:

Remember that no file is created by function tempfile.

SEE ALSO:

, .

EXAMPLES:

# an intermediate file for editing 
my.ed <- function(x, file = tempfile("ed")) { 
        if(missing(file)) on.exit(unlink(file)) 
        dput(x, file=file) 
        unix(paste("ed", file), output=F) 
        parse(file=file)[[1]] 
}                
  tempfile(c("fileA", "fileB"))      
[1] "/tmp/fileA13407" "/tmp/fileB13407"