R: Temporary files

with_tempfile {withr} | R Documentation

## Temporary files

### Description

Temporarily create a tempfile, which is automatically removed afterwards.

### Usage

    with_tempfile(new, code, envir = parent.frame(), pattern = "file",
      tmpdir = tempdir(), fileext = "")

    local_tempfile(new, envir = parent.frame(), pattern = "file",
      tmpdir = tempdir(), fileext = "")

### Arguments

`new` | `[character vector]` Names of temporary file handles to create.
`code` | `[any]` Code to execute in the temporary environment
`envir` | `[environment]` Environment in which to define the temporary files.
`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

### Value

`[any]`
The results of the evaluation of the `code` argument.

### See Also

`withr` for examples

[Package withr version 2.1.1 Index]