Create files, which are then automatically removed afterwards.
with_file(file, code)local_file(.file, ..., .local_envir = parent.frame())
local_file(.file, ..., .local_envir = parent.frame())
[any] The results of the evaluation of the code
[any]
code
argument.
[named list] Files to create.
[named list]
[any] Code to execute in the temporary environment
Additional (possibly named) arguments of files to create.
[environment] The environment to use for scoping.
[environment]
withr for examples
withr
with_file("file1", { writeLines("foo", "file1") readLines("file1") }) with_file(list("file1" = writeLines("foo", "file1")), { readLines("file1") })
Run the code above in your browser using DataLab