tempfile
Create Unique Names for Files
Description
Returns a vector of character strings that are virtually certain to be 
unique filenames.
Usage
tempfile(pattern = "file", tmpdir = tempdir(), fileext = "")
tempdir(check = FALSE)
Arguments
| pattern | a vector of character strings to form the beginnings of the returned
filenames. | 
| tmpdir | the base directory for the filenames. | 
| fileext | a string containing the filename extension. | 
| check | a logical value.  If TRUE, and if tempdir(FALSE), then 
tempfile does not name an existing directory. Instead, a new, 
randomly-named directory is created and its name is returned.  
This design allows tempfile()) to work after the TERR temporary 
directory is removed (which can happen on systems that periodically remove 
old, temporary files). | 
 
Details
Remember that no file is created by the function the tempfile.
The length of the vector in the result of tempfile depends on 
the maximum value of the length of pattern and tmpdir.
The returned file names use backslashes as the file path separator on
Windows, and forward slashes on other platforms.  Thus, these
filenames can be passed to system when calling Windows system
applications that only accept file names with backslashes.
Value
| tempfile | returns a vector of character strings containing 
the names of files that can be used as temporary files. (pattern 
sets the first character(s) in each file name, and then each name is 
appended by a generated number.) The names are virtually certain to be 
unique from one call to the next. | 
| tempdir | returns the name of a directory in which 
temporary file names are written. At the start of the session, this directory is created. 
At the end of the session, this directory is removed,
along with all temporary files in it. | 
 
See Also
Examples
# Create a directory
tmpdir <- tempfile('foo')
dir.create(tmpdir)
# Create a file in that directory
tmpfile <- tempfile('bar', tmpdir)
cat('hello', file=tmpfile)