Learn R Programming

fritools (version 4.6.0)

with_dir: Execute Code in a Temporary Working Directory

Description

This is a verbatim copy of withr::with_dir from of withr's version 2.4.1. I often need withr only to import withr::with_dir, which is a really simple function. So I just hijack withr::with_dir.

Usage

with_dir(new, code)

Value

The results of the evaluation of the code argument.

Arguments

new

The new working directory.

code

Code to execute in the temporary working directory.

See Also

Other operating system functions: clipboard_path(), file_copy(), file_save(), get_boolean_envvar(), get_run_r_tests(), is_installed(), is_r_package_installed(), is_success(), is_windows(), view(), vim(), wipe_tempdir()

Examples

Run this code
temp_dir <- file.path(tempfile())
dir.create(temp_dir)
with_dir(temp_dir, getwd())

Run the code above in your browser using DataLab