tempfile(pattern="file") tempdir()
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.
Remember that no file is created by function
tempfile
.
# 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"