Skip to contents

Temporarily change the current working directory.

Usage

with_dir(new, code)

local_dir(new = list(), .local_envir = parent.frame())

Arguments

new

[character(1)]
New working directory

code

[any]
Code to execute in the temporary environment

.local_envir

[environment]
The environment to use for scoping.

Value

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

See also

withr for examples

setwd()

Examples

getwd()
#> [1] "/tmp/.tmp7S8S1R/docs/withr/3.0.3/src/docs/reference"

with_dir(tempdir(), getwd())
#> [1] "/tmp/RtmpZ05IdX"