tempfile returns a vector of character strings which can be used as names for temporary files.
<!-- % ../R/temp.R -->
tempfile(pattern = "file", tmpdir = tempdir(), fileext = "")
tempdir(check = FALSE)
| Parameter | Description |
|---|---|
pattern |
a non-empty character vector giving the initial part of the name. |
tmpdir |
a non-empty character vector giving the directory name |
fileext |
a non-empty character vector giving the file extension |
check |
logical indicating if tmpdir() should be checked and recreated if no longer valid. |
# NOT RUN {
tempfile(c("ab", "a b c")) # give file name with spaces in!
tempfile("plot", fileext = c(".ps", ".pdf"))
tempdir() # works on all platforms with a platform-dependent result
# }
# NOT RUN {
## Show how 'check' is working on some platforms:
if(exists("I'm brave") && `I'm brave` &&
identical(.Platform$OS.type, "unix") && grepl("^/tmp/", tempdir())) {
cat("Current tempdir(): ", tempdir(), "\n")
cat("Removing it :", file.remove(tempdir()),
"; dir.exists(tempdir()):", dir.exists(tempdir()), "\n")
cat("and now tempdir(check = TRUE) :", tempdir(check = TRUE),"\n")
}
# }