tempfile {base} | R Documentation |
Returns a vector of character strings which can be used as unique names for (temporary) files.
tempfile(pattern = "file")
pattern |
a character vector giving the initial part of the name. |
A character vector giving the names of possible (temporary) files.
The names are guaranteed to be unique among calls to tempfile
in an R session. Note that no files are generated by tempfile
.
unlink
for deleting files.
## One possibility of getting ALL environment variables; ## compare with `getenv': fun <- function() { FILE <- tempfile("fun") on.exit(unlink(FILE)) system(paste("printenv >", FILE)) x <- strsplit(scan(FILE, what = ""), "=") v <- n <- character(LEN <- length(x)) for (i in 1:LEN) { n[i] <- x[[i]][1] v[i] <- paste(x[[i]][-1], collapse = "=") } structure(v, names = n) } fun()