Learn R Programming

fs (version 1.0.0)

file_temp: Create names for temporary files

Description

file_temp() returns the name which can be used as a temporary file.

Usage

file_temp(pattern = "file", tmp_dir = tempdir(), ext = "")

file_temp_push(path)

file_temp_pop()

Arguments

pattern

A character vector with the non-random portion of the name.

tmp_dir

The directory the file will be created in.

ext

The file extension of the temporary file.

path

A character vector of one or more paths.

Details

file_temp_push() can be used to supply deterministic entries in the temporary file stack. This can be useful for reproducibility in like example documentation and vignettes.

file_temp_pop() can be used to explicitly remove an entry from the internal stack, however generally this is done instead by calling file_temp().

Examples

Run this code
# NOT RUN {
# default just passes the arguments to `tempfile()`
file_temp()

# But you can also make the results deterministic
file_temp_push(letters)
file_temp()
file_temp()

# Or explicitly remove values
while (!is.null(file_temp_pop())) next
file_temp_pop()
# }

Run the code above in your browser using DataLab