Make a temporary file in a temporary (sub-)directory

tempfile2(
  sub = "",
  tempdir = getOption("reproducible.tempPath", .reproducibleTempPath()),
  ...
)

Arguments

sub

Character string, length 1. Can be a result of file.path("smth", "smth2") for nested temporary subdirectories. If the zero length character, then a random sub-directory will be created.

tempdir

Optional character string where the temporary directory should be placed. Defaults to getOption("reproducible.tempPath").

...

passed to tempfile, e.g., fileext

Value

A character string of a path to a file in a sub-directory of the tempdir(). This file will likely not exist yet.

See also

Examples

tf <- tempfile2("myProject", fileext = ".csv")
basename(tf)
#> [1] "file21027d5f9c0c.csv"
unlink(dirname(tf), recursive = TRUE)