Skip to contents

Change the working directory, evaluate the expression, and restore the working directory.

Usage

in_dir(dir, expr)

Arguments

dir

Path to a directory.

expr

An R expression.

Examples

library(xfun)
in_dir(tempdir(), {
    print(getwd())
    list.files()
})
#> [1] "/tmp/Rtmp3s6YZ5"
#> [1] "bslib-159addef584386bde93c7b3b649dce09"
#> [2] "downlit"                               
#> [3] "file38dabe1296612d"                    
#> [4] "file38dabe2e12a818"                    
#> [5] "file38dabe404c5728"